pub struct UserSession(/* private fields */);Expand description
axum extractor:要求用户已登录,否则返回 401。
通过 Deref/DerefMut 可直接访问内部 Session 的所有方法。
Methods from Deref<Target = Session>§
Sourcepub fn get_account(&self) -> &str
pub fn get_account(&self) -> &str
返回当前登录的用户账号。
Sourcepub fn get_user_id(&self) -> i64
pub fn get_user_id(&self) -> i64
返回当前登录的用户 ID。
Sourcepub fn get_expired_at(&self) -> String
pub fn get_expired_at(&self) -> String
返回 Session 过期时间的格式化字符串。
Sourcepub fn is_will_expired(&self) -> bool
pub fn is_will_expired(&self) -> bool
返回 true 表示 Session 将在 1 小时内过期。
Sourcepub fn get_issued_at(&self) -> String
pub fn get_issued_at(&self) -> String
返回 Session 签发时间的格式化字符串。
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
返回 true 表示 Session 已超过 TTL 过期。
Trait Implementations§
Source§impl Deref for UserSession
impl Deref for UserSession
Source§impl DerefMut for UserSession
impl DerefMut for UserSession
Source§impl From<UserSession> for Session
impl From<UserSession> for Session
Source§fn from(se: UserSession) -> Self
fn from(se: UserSession) -> Self
Converts to this type from the input type.
Source§impl<S> FromRequestParts<S> for UserSession
impl<S> FromRequestParts<S> for UserSession
Auto Trait Implementations§
impl Freeze for UserSession
impl !RefUnwindSafe for UserSession
impl Send for UserSession
impl Sync for UserSession
impl Unpin for UserSession
impl UnsafeUnpin for UserSession
impl !UnwindSafe for UserSession
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
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
Source§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
Perform the extraction.