pub struct AdminSession(/* private fields */);Expand description
axum extractor:要求用户已登录且具有 Admin 或 SuperAdmin 角色,否则返回 401/403。
通过 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 AdminSession
impl Deref for AdminSession
Source§impl DerefMut for AdminSession
impl DerefMut for AdminSession
Source§impl From<AdminSession> for Session
impl From<AdminSession> for Session
Source§fn from(se: AdminSession) -> Self
fn from(se: AdminSession) -> Self
Converts to this type from the input type.
Source§impl<S> FromRequestParts<S> for AdminSession
impl<S> FromRequestParts<S> for AdminSession
Auto Trait Implementations§
impl Freeze for AdminSession
impl !RefUnwindSafe for AdminSession
impl Send for AdminSession
impl Sync for AdminSession
impl Unpin for AdminSession
impl UnsafeUnpin for AdminSession
impl !UnwindSafe for AdminSession
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.