pub struct NonceManager { /* private fields */ }Expand description
Nonce Manager | Nonce 管理器
Implementations§
Source§impl NonceManager
impl NonceManager
Sourcepub fn from_dao(dao: Arc<SaTokenDao>, timeout: i64) -> Self
pub fn from_dao(dao: Arc<SaTokenDao>, timeout: i64) -> Self
Create from Dao | 从 Dao 创建
Sourcepub fn new(storage: Arc<dyn SaStorage>, timeout: i64) -> Self
pub fn new(storage: Arc<dyn SaStorage>, timeout: i64) -> Self
Legacy wrapper: builds a Dao with default config + given timeout. 遗留包装:用默认配置构造 Dao。
Sourcepub fn with_serializer(self, serializer: SharedSerializer) -> Self
pub fn with_serializer(self, serializer: SharedSerializer) -> Self
Align serializer with Manager / config (A2-1). 与 Manager / 配置对齐序列化器(A2-1)。
Sourcepub async fn store(&self, nonce: &str, login_id: &str) -> SaTokenResult<()>
pub async fn store(&self, nonce: &str, login_id: &str) -> SaTokenResult<()>
Store and mark nonce as used | 存储并标记 nonce 为已使用
Sourcepub async fn get_record(
&self,
nonce: &str,
) -> SaTokenResult<Option<NonceRecord>>
pub async fn get_record( &self, nonce: &str, ) -> SaTokenResult<Option<NonceRecord>>
Retrieve nonce record for audit (optional) | 检索 nonce 记录(审计可选)
Sourcepub async fn validate(&self, nonce: &str) -> SaTokenResult<bool>
pub async fn validate(&self, nonce: &str) -> SaTokenResult<bool>
Validate nonce and ensure it hasn’t been used | 验证 nonce 并确保未被使用
Sourcepub async fn validate_and_consume(
&self,
nonce: &str,
login_id: &str,
) -> SaTokenResult<()>
pub async fn validate_and_consume( &self, nonce: &str, login_id: &str, ) -> SaTokenResult<()>
Validate and consume nonce atomically via set_if_absent. 通过 set_if_absent 原子校验并消费 nonce。
Sourcepub fn check_timestamp(
&self,
nonce: &str,
window_seconds: i64,
) -> SaTokenResult<bool>
pub fn check_timestamp( &self, nonce: &str, window_seconds: i64, ) -> SaTokenResult<bool>
Extract timestamp from nonce and check if it’s within valid time window 从 nonce 中提取时间戳并检查是否在有效时间窗口内
Sourcepub async fn cleanup_expired(&self) -> SaTokenResult<usize>
pub async fn cleanup_expired(&self) -> SaTokenResult<usize>
Scan and remove expired nonce records | 扫描并删除过期 nonce 记录
Trait Implementations§
Source§impl Clone for NonceManager
impl Clone for NonceManager
Source§fn clone(&self) -> NonceManager
fn clone(&self) -> NonceManager
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 moreAuto Trait Implementations§
impl !RefUnwindSafe for NonceManager
impl !UnwindSafe for NonceManager
impl Freeze for NonceManager
impl Send for NonceManager
impl Sync for NonceManager
impl Unpin for NonceManager
impl UnsafeUnpin for NonceManager
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