pub struct SaTokenContext {
pub token: Option<TokenValue>,
pub token_info: Option<Arc<TokenInfo>>,
pub login_id: Option<String>,
}Expand description
sa-token 上下文 | sa-token Context
§字段说明 | Field Description
token: 当前请求的 token | Current request’s tokentoken_info: Token 详细信息 | Token detailed informationlogin_id: 登录用户 ID | Logged-in user ID
Fields§
§token: Option<TokenValue>当前请求的 token | Current request’s token
token_info: Option<Arc<TokenInfo>>当前请求的 token 信息 | Current request’s token info
login_id: Option<String>登录 ID | Login ID
Implementations§
Source§impl SaTokenContext
impl SaTokenContext
pub fn new() -> Self
Sourcepub async fn scope<F, R>(ctx: SaTokenContext, fut: F) -> Rwhere
F: Future<Output = R>,
pub async fn scope<F, R>(ctx: SaTokenContext, fut: F) -> Rwhere
F: Future<Output = R>,
Bind ctx for the whole lifetime of fut (await-safe across worker threads).
在 fut 全生命周期内绑定 ctx(跨 await / 跨 worker 仍有效)。
Sourcepub fn try_current() -> Option<SaTokenContext>
pub fn try_current() -> Option<SaTokenContext>
Clone of current context: task-local first, then thread-local fallback. 当前上下文副本:优先 task-local,再回落 thread-local。
Sourcepub fn set_current(ctx: SaTokenContext)
pub fn set_current(ctx: SaTokenContext)
设置当前上下文(thread-local 兼容路径)| Set current context (thread-local compat)
Sourcepub fn get_current() -> Option<SaTokenContext>
pub fn get_current() -> Option<SaTokenContext>
获取当前上下文 | Get current context
Trait Implementations§
Source§impl Clone for SaTokenContext
impl Clone for SaTokenContext
Source§fn clone(&self) -> SaTokenContext
fn clone(&self) -> SaTokenContext
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 Debug for SaTokenContext
impl Debug for SaTokenContext
Auto Trait Implementations§
impl Freeze for SaTokenContext
impl RefUnwindSafe for SaTokenContext
impl Send for SaTokenContext
impl Sync for SaTokenContext
impl Unpin for SaTokenContext
impl UnsafeUnpin for SaTokenContext
impl UnwindSafe for SaTokenContext
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