pub struct GrantScope { /* private fields */ }Expand description
请求级授权快照(B2 特性,与 SaTokenContext 平行存储)
Request-scoped authorization snapshot (B2 feature, stored in parallel with SaTokenContext).
内部用 Arc<RwLock<HashMap>>:SaTokenContext::current_grant_scope 返回的是
克隆,但克隆共享同一份数据,因此在请求任意位置写入都能被后续读取看到。
Backed by Arc<RwLock<HashMap>>: current_grant_scope hands out clones that
share one map, so a write anywhere in the request is visible to later reads.
Implementations§
Source§impl GrantScope
impl GrantScope
Sourcepub fn remove(&self, key: &str)
pub fn remove(&self, key: &str)
移除快照项(权限写操作后调用,使请求立即看到新值)
Remove an entry after a write so the request sees the new value at once.
Sourcepub async fn run<F, T>(scope: Self, future: F) -> Twhere
F: Future<Output = T>,
pub async fn run<F, T>(scope: Self, future: F) -> Twhere
F: Future<Output = T>,
在给定 Future 期间挂载本快照(独立 API,兼容 B2)
Mounts this snapshot for the duration of a future (standalone API, B2 compat).
优先使用 SaTokenContext::scope(正常 Web 请求同时需要 token + grant)。
Prefer SaTokenContext::scope for normal Web requests needing both token and grant.
Trait Implementations§
Source§impl Clone for GrantScope
impl Clone for GrantScope
Source§fn clone(&self) -> GrantScope
fn clone(&self) -> GrantScope
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 GrantScope
impl Debug for GrantScope
Source§impl Default for GrantScope
impl Default for GrantScope
Source§fn default() -> GrantScope
fn default() -> GrantScope
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for GrantScope
impl RefUnwindSafe for GrantScope
impl Send for GrantScope
impl Sync for GrantScope
impl Unpin for GrantScope
impl UnsafeUnpin for GrantScope
impl UnwindSafe for GrantScope
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