# IdentityPolicy in actix_identity - Rust
Identity policy.
Keywords: rust, rustlang, rust-lang, IdentityPolicy

# Trait actix_identity::IdentityPolicy

source · [−]

    pub trait IdentityPolicy: Sized + 'static {
        type Future: Future<Output = Result<Option<String>, Error>>;
        type ResponseFuture: Future<Output = Result<(), Error>>;
        fn from_request(&self, req: &mut ServiceRequest) -> Self::Future;
        fn to_response<B>(
            &self,
            identity: Option<String>,
            changed: bool,
            response: &mut ServiceResponse<B>
        ) -> Self::ResponseFuture;
    }

Expand description

Identity policy.

## Associated Types

source

#### type Future: Future<Output = Result<Option<String>, Error>>

The return type of the middleware

source

#### type ResponseFuture: Future<Output = Result<(), Error>>

The return type of the middleware

## Required methods

source

#### fn from_request(&self, req: &mut ServiceRequest) -> Self::Future

Parse the session from request and load data from a service identity.

source

#### fn to_response<B>(
&self,
identity: Option<String>,
changed: bool,
response: &mut ServiceResponse<B>
) -> Self::ResponseFuture

Write changes to response

## Implementors

source

### impl IdentityPolicy for CookieIdentityPolicy

#### type Future = Ready<Result<Option<String>, Error>>

#### type ResponseFuture = Ready<Result<(), Error>>