Struct actix_identity::Identity [−][src]
The extractor type to obtain your identity from a request.
use actix_web::*; use actix_identity::Identity; fn index(id: Identity) -> Result<String> { // access request identity if let Some(id) = id.identity() { Ok(format!("Welcome! {}", id)) } else { Ok("Welcome Anonymous!".to_owned()) } } fn login(id: Identity) -> HttpResponse { id.remember("User1".to_owned()); // <- remember identity HttpResponse::Ok().finish() } fn logout(id: Identity) -> HttpResponse { id.forget(); // <- remove identity HttpResponse::Ok().finish() }
Implementations
impl Identity
[src]
pub fn identity(&self) -> Option<String>
[src]
Return the claimed identity of the user associated request or
None
if no identity can be found associated with the request.
pub fn remember(&self, identity: String)
[src]
Remember identity.
pub fn forget(&self)
[src]
This method is used to ‘forget’ the current identity on subsequent requests.
Trait Implementations
impl Clone for Identity
[src]
impl FromRequest for Identity
[src]
Extractor implementation for Identity type.
use actix_identity::Identity; fn index(id: Identity) -> String { // access request identity if let Some(id) = id.identity() { format!("Welcome! {}", id) } else { "Welcome Anonymous!".to_owned() } }
type Config = ()
Configuration for this extractor.
type Error = Error
The associated error which can be returned.
type Future = Ready<Result<Identity, Error>>
Future that resolves to a Self.
fn from_request(req: &HttpRequest, _: &mut Payload) -> Self::Future
[src]
pub fn extract(req: &HttpRequest) -> Self::Future
pub fn configure<F>(f: F) -> Self::Config where
F: FnOnce(Self::Config) -> Self::Config,
F: FnOnce(Self::Config) -> Self::Config,
Auto Trait Implementations
impl !RefUnwindSafe for Identity
impl !Send for Identity
impl !Sync for Identity
impl Unpin for Identity
impl !UnwindSafe for Identity
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,