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§impl<U: Debug> Debug for AuthenticatedUser<U>
impl<U: Debug> Debug for AuthenticatedUser<U>
Source§impl<U> Deref for AuthenticatedUser<U>
impl<U> Deref for AuthenticatedUser<U>
Source§impl<U: Send + Sync + 'static> FromRequest for AuthenticatedUser<U>
The authenticated user, as a controller parameter.
impl<U: Send + Sync + 'static> 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.
Source§fn from_request(request: Arc<Request>) -> BoxedFuture<Result<Self>>
fn from_request(request: Arc<Request>) -> BoxedFuture<Result<Self>>
Build
Self from the request, or fail with the error the client should
see (a 400 for a malformed body, a 422 for a failed contract).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> 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.