pub struct AuthenticatedUser<U>(pub Arc<U>);Expand description
The user resolved for this request, stored in its extensions.
A newtype rather than a bare U so it cannot be confused with any other
value of the same type an application might attach.
Tuple Fields§
§0: Arc<U>Implementations§
Trait Implementations§
Source§impl<U> Clone for AuthenticatedUser<U>
Cloning shares the user rather than copying it, so this holds whatever U
is — a derived Clone would have demanded U: Clone for no reason.
impl<U> Clone for AuthenticatedUser<U>
Cloning shares the user rather than copying it, so this holds whatever U
is — a derived Clone would have demanded U: Clone for no reason.
Source§fn clone(&self) -> AuthenticatedUser<U>
fn clone(&self) -> AuthenticatedUser<U>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<U> Debug for AuthenticatedUser<U>where
U: Debug,
impl<U> Debug for AuthenticatedUser<U>where
U: Debug,
Source§impl<U> Deref for AuthenticatedUser<U>
impl<U> Deref for AuthenticatedUser<U>
Source§impl<U> FromRequest for AuthenticatedUser<U>
The authenticated user, as a controller parameter.
impl<U> FromRequest for AuthenticatedUser<U>
The authenticated user, as a controller parameter.
The framework supplies it, which is why an action can read
ⓘ
pub async fn me(user: AuthenticatedUser<User>) -> Result<Response> {
Ok(Response::json(user.get()))
}rather than taking the whole request and digging the user out of it.
Fails with 401 when there is none — which can only happen on a route with
no Authenticate middleware in front, so the message says so rather than
blaming the caller for a wiring mistake.
Auto Trait Implementations§
impl<U> Freeze for AuthenticatedUser<U>
impl<U> RefUnwindSafe for AuthenticatedUser<U>where
Arc<U>: RefUnwindSafe,
impl<U> Send for AuthenticatedUser<U>
impl<U> Sync for AuthenticatedUser<U>
impl<U> Unpin for AuthenticatedUser<U>
impl<U> UnsafeUnpin for AuthenticatedUser<U>where
Arc<U>: UnsafeUnpin,
impl<U> UnwindSafe for AuthenticatedUser<U>where
Arc<U>: UnwindSafe,
Blanket Implementations§
impl<T> Actor for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, A> DynAccess<T> for A
impl<T, A> DynAccess<T> for A
Source§fn load(&self) -> DynGuard<T>
fn load(&self) -> DynGuard<T>
The equivalent of
Access::load.Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
A human-readable name, used by wildcard listeners and log output.
Always the Rust type path; see the trait docs.
impl<T> Formattable for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.