RUser

Struct RUser 

Source
pub struct RUser {
    pub id: String,
    pub token: String,
}
Expand description

An authenticated request context extracted from actix-web.

If extraction succeeds, id is the user id previously passed to RTokenManager::login, and token is the original token from the request.

The token is read from Authorization header. Both of the following formats are accepted:

  • Authorization: <token>
  • Authorization: Bearer <token>

§繁體中文

由 actix-web 自動抽取的已驗證使用者上下文。

Extractor 成功時:

  • id 會是先前傳給 RTokenManager::login 的使用者 id
  • token 會是請求中帶來的 token 原文

token 會從 Authorization header 讀取,支援以下格式:

  • Authorization: <token>
  • Authorization: Bearer <token>

Fields§

§id: String

The user id associated with the token.

§繁體中文

與 token 綁定的使用者 id。

§token: String

The raw token string from the request.

§繁體中文

來自請求的 token 字串原文。

Trait Implementations§

Source§

impl Debug for RUser

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromRequest for RUser

Available on crate feature actix only.

Extracts RUser from an actix-web request.

Failure modes:

  • 500: manager is missing from app_data, or mutex is poisoned
  • 401: token is missing, invalid, or expired
§繁體中文

從 actix-web 請求中抽取 RUser

失敗情況:

  • 500:app_data 中找不到管理器,或 mutex poisoned
  • 401:token 缺失、無效、或已過期
Source§

type Error = Error

The associated error which can be returned.
Source§

type Future = Ready<Result<RUser, <RUser as FromRequest>::Error>>

Future that resolves to a Self. Read more
Source§

fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future

Create a Self from request parts asynchronously.
Source§

fn extract(req: &HttpRequest) -> Self::Future

Create a Self from request head asynchronously. Read more

Auto Trait Implementations§

§

impl Freeze for RUser

§

impl RefUnwindSafe for RUser

§

impl Send for RUser

§

impl Sync for RUser

§

impl Unpin for RUser

§

impl UnwindSafe for RUser

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more