pub struct OptionalAuthUser(pub Option<Arc<AuthIdentity>>);Expand description
OptionalAuthUser Extractor
A request extractor that provides optional authentication.
Unlike AuthUser, this succeeds even when no identity is present,
returning None in that case.
§Usage
async fn handler(user: OptionalAuthUser) -> impl IntoResponse {
match user.value() {
Some(identity) => format!("Hello, {}", identity.subject),
None => "Hello, guest".to_string(),
}
}Tuple Fields§
§0: Option<Arc<AuthIdentity>>Trait Implementations§
Source§impl Clone for OptionalAuthUser
impl Clone for OptionalAuthUser
Source§fn clone(&self) -> OptionalAuthUser
fn clone(&self) -> OptionalAuthUser
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OptionalAuthUser
impl Debug for OptionalAuthUser
Source§impl Default for OptionalAuthUser
impl Default for OptionalAuthUser
Source§fn default() -> OptionalAuthUser
fn default() -> OptionalAuthUser
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for OptionalAuthUser
impl RefUnwindSafe for OptionalAuthUser
impl Send for OptionalAuthUser
impl Sync for OptionalAuthUser
impl Unpin for OptionalAuthUser
impl UnsafeUnpin for OptionalAuthUser
impl UnwindSafe for OptionalAuthUser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more