pub struct SaKeys { /* private fields */ }Expand description
Storage key builder — the single source of truth for key schema 存储键构造器 —— 键 schema 的唯一来源
Implementations§
Source§impl SaKeys
impl SaKeys
Sourcepub fn new(prefix: impl AsRef<str>) -> Self
pub fn new(prefix: impl AsRef<str>) -> Self
Creates a builder with the default SaKeyLayout::ThreeSegment layout
使用默认 SaKeyLayout::ThreeSegment 布局创建构造器
Sourcepub fn with_layout(root: impl AsRef<str>, layout: SaKeyLayout) -> Self
pub fn with_layout(root: impl AsRef<str>, layout: SaKeyLayout) -> Self
Creates a builder with an explicit layout | 使用显式布局创建构造器
Sourcepub fn from_config(config: &SaTokenConfig) -> Self
pub fn from_config(config: &SaTokenConfig) -> Self
Builds from config, honouring key_layout (A3-1) | 从配置构建,遵循 key_layout(A3-1)
Sourcepub fn layout(&self) -> SaKeyLayout
pub fn layout(&self) -> SaKeyLayout
Returns the active layout | 返回生效的布局
Sourcepub fn account_ns(login_type: &str, login_id: &LoginId) -> AccountNs
pub fn account_ns(login_type: &str, login_id: &LoginId) -> AccountNs
Normalizes (login_type, login_id) into a single key segment (A3-2, A3-16)
将 (login_type, login_id) 归一为单个键段(A3-2、A3-16)
Sourcepub fn is_default_login_type(login_type: &str) -> bool
pub fn is_default_login_type(login_type: &str) -> bool
Returns true for login types normalized to the bare id
对归一为裸 id 的账号体系返回 true
Sourcepub fn validate_login_id(login_id: &str) -> Result<(), KeyError>
pub fn validate_login_id(login_id: &str) -> Result<(), KeyError>
Validates a login_id before it is used in a key (A3-16)
在 login_id 用于构造键之前校验它(A3-16)
Sourcepub fn make_key(&self, suffix: &str, id: &str) -> String
👎Deprecated since 0.1.19: Use a named key method (token_info / login_token / …) so the key layout is respected
pub fn make_key(&self, suffix: &str, id: &str) -> String
Use a named key method (token_info / login_token / …) so the key layout is respected
Deprecated escape hatch kept for legacy call sites (A3-10) 为存量调用点保留的已弃用逃生舱(A3-10)
Sourcepub fn token_info(&self, token: &str) -> String
pub fn token_info(&self, token: &str) -> String
Token → login_id mapping key | Token → login_id 映射键
Sourcepub fn token_info_with_type(&self, login_type: &str, token: &str) -> String
pub fn token_info_with_type(&self, login_type: &str, token: &str) -> String
Token key for a specific account system (A3-4) | 指定账号体系的 Token 键(A3-4)
Sourcepub fn token_id_mapping(&self, token: &str) -> String
pub fn token_id_mapping(&self, token: &str) -> String
Reverse token → id mapping key (Rust-specific) | 反向 token → id 映射键(Rust 独有)
Sourcepub fn token_session(&self, token: &str) -> String
pub fn token_session(&self, token: &str) -> String
Token-Session key | Token-Session 键
Sourcepub fn token_session_with_type(&self, login_type: &str, token: &str) -> String
pub fn token_session_with_type(&self, login_type: &str, token: &str) -> String
Token-Session key for a specific account system (A3-4) 指定账号体系的 Token-Session 键(A3-4)
Sourcepub fn last_active(&self, token: &str) -> String
pub fn last_active(&self, token: &str) -> String
Last-active timestamp key | 最后活跃时间键
Sourcepub fn last_active_with_type(&self, login_type: &str, token: &str) -> String
pub fn last_active_with_type(&self, login_type: &str, token: &str) -> String
Last-active key for a specific account system (A3-4) 指定账号体系的最后活跃时间键(A3-4)
Sourcepub fn login_token(&self, login_type: &str, login_id: &str) -> String
pub fn login_token(&self, login_type: &str, login_id: &str) -> String
login_id → token mapping key (Rust-specific) | login_id → token 映射键(Rust 独有)
Sourcepub fn login_token_index(&self, login_type: &str, login_id: &str) -> String
pub fn login_token_index(&self, login_type: &str, login_id: &str) -> String
Multi-device token index key (Rust-specific) | 多设备 token 索引键(Rust 独有)
Sourcepub fn account_session(&self, login_type: &str, login_id: &str) -> String
pub fn account_session(&self, login_type: &str, login_id: &str) -> String
Account-Session key | Account-Session 键
Sourcepub fn session_by_ns(&self, ns: &AccountNs) -> Result<String, KeyError>
pub fn session_by_ns(&self, ns: &AccountNs) -> Result<String, KeyError>
Account-Session key from an already-namespaced id (A3-2) 从已命名空间化 id 构造 Account-Session 键(A3-2)
Sourcepub fn permission(&self, login_type: &str, login_id: &str) -> String
pub fn permission(&self, login_type: &str, login_id: &str) -> String
Permission list key | 权限列表键
Sourcepub fn disable(&self, login_type: &str, login_id: &str, service: &str) -> String
pub fn disable(&self, login_type: &str, login_id: &str, service: &str) -> String
Account ban (disable) key | 账号封禁键
Sourcepub fn disable_by_ns(
&self,
ns: &AccountNs,
service: &str,
) -> Result<String, KeyError>
pub fn disable_by_ns( &self, ns: &AccountNs, service: &str, ) -> Result<String, KeyError>
Ban key from an already-namespaced id (A3-2) | 从已命名空间化 id 构造封禁键(A3-2)
Sourcepub fn safe(&self, token: &str, service: &str) -> String
pub fn safe(&self, token: &str, service: &str) -> String
Second-factor (safe) verification key | 二级认证键
Sourcepub fn safe_with_type(
&self,
login_type: &str,
token: &str,
service: &str,
) -> String
pub fn safe_with_type( &self, login_type: &str, token: &str, service: &str, ) -> String
Second-factor key for a specific account system | 指定账号体系的二级认证键
Sourcepub fn refresh_user_index(&self, login_type: &str, login_id: &str) -> String
pub fn refresh_user_index(&self, login_type: &str, login_id: &str) -> String
Per-account refresh token index key | 按账号的 Refresh Token 索引键
Sourcepub fn refresh_user_index_by_ns(
&self,
ns: &AccountNs,
) -> Result<String, KeyError>
pub fn refresh_user_index_by_ns( &self, ns: &AccountNs, ) -> Result<String, KeyError>
Refresh index key from an already-namespaced id (A3-2) 从已命名空间化 id 构造 Refresh 索引键(A3-2)
Sourcepub fn oauth2_client(&self, client_id: &str) -> String
pub fn oauth2_client(&self, client_id: &str) -> String
OAuth2 client registration key | OAuth2 客户端注册键
Sourcepub fn oauth2_code(&self, code: &str) -> String
pub fn oauth2_code(&self, code: &str) -> String
OAuth2 authorization code key | OAuth2 授权码键
Sourcepub fn oauth2_token(&self, access_token: &str) -> String
pub fn oauth2_token(&self, access_token: &str) -> String
OAuth2 access token key | OAuth2 访问令牌键
Sourcepub fn oauth2_refresh(&self, refresh_token: &str) -> String
pub fn oauth2_refresh(&self, refresh_token: &str) -> String
OAuth2 refresh token key | OAuth2 刷新令牌键
Sourcepub fn sso_ticket(&self, ticket_id: &str) -> String
pub fn sso_ticket(&self, ticket_id: &str) -> String
SSO ticket key | SSO 票据键
Sourcepub fn sso_session(&self, login_id: &str) -> String
pub fn sso_session(&self, login_id: &str) -> String
SSO session key | SSO 会话键
Sourcepub fn sso_login_token(&self, login_type: &str, login_id: &str) -> String
pub fn sso_login_token(&self, login_type: &str, login_id: &str) -> String
SSO login-token key | SSO 登录令牌键
Sourcepub fn online_with_type(
&self,
login_type: &str,
login_id: &str,
token: &str,
) -> String
pub fn online_with_type( &self, login_type: &str, login_id: &str, token: &str, ) -> String
Online-user record key for a specific account system (A3-13) 指定账号体系的在线用户记录键(A3-13)
Sourcepub fn online_index(&self, login_id: &str) -> String
pub fn online_index(&self, login_id: &str) -> String
Online-user index key | 在线用户索引键
Sourcepub fn online_index_with_type(&self, login_type: &str, login_id: &str) -> String
pub fn online_index_with_type(&self, login_type: &str, login_id: &str) -> String
Online-user index key for a specific account system. 指定账号体系的在线用户索引键。
Sourcepub fn online_users_set(&self) -> String
pub fn online_users_set(&self) -> String
Global unique set of currently online login ids (list primitive). 当前在线账号 ID 的全局去重集合(走列表原语)。
Sourcepub fn distributed_session(&self, session_id: &str) -> String
pub fn distributed_session(&self, session_id: &str) -> String
Distributed session key | 分布式会话键
Sourcepub fn distributed_session_index(&self, login_id: &str) -> String
pub fn distributed_session_index(&self, login_id: &str) -> String
Distributed session index key | 分布式会话索引键
Sourcepub fn distributed_service(&self, service_id: &str) -> String
pub fn distributed_service(&self, service_id: &str) -> String
Distributed service credential key | 分布式服务凭证键
Sourcepub fn same_token(&self) -> String
pub fn same_token(&self) -> String
Current Same-Token storage key. 当前 Same-Token 存储键。
Sourcepub fn same_token_past(&self) -> String
pub fn same_token_past(&self) -> String
Previous Same-Token storage key (grace window). 上一次 Same-Token 存储键(宽限期)。
Sourcepub fn sign_nonce(&self, nonce: &str) -> String
pub fn sign_nonce(&self, nonce: &str) -> String
Request-sign nonce occupancy key (not the login nonce space). 请求签名 nonce 占位键(与登录 nonce 键空间分离)。
Sourcepub fn temp_token(&self, namespace: &str, token: &str) -> String
pub fn temp_token(&self, namespace: &str, token: &str) -> String
Temp-token body key. 临时令牌体键。
Sourcepub fn temp_index(&self, namespace: &str, value_digest: &str) -> String
pub fn temp_index(&self, namespace: &str, value_digest: &str) -> String
Temp-token reverse index (digest of the string value). 临时令牌反查索引(字符串 value 的摘要)。
Sourcepub fn category_prefix(
&self,
category: &str,
login_type: Option<&str>,
) -> String
pub fn category_prefix( &self, category: &str, login_type: Option<&str>, ) -> String
Returns the key prefix for a category, layout-aware (A3-11) 返回某分类的键前缀,布局感知(A3-11)
Sourcepub fn token_key_prefix(&self, login_type: Option<&str>) -> String
pub fn token_key_prefix(&self, login_type: Option<&str>) -> String
Token key prefix, for scan-and-strip workflows (A3-11) Token 键前缀,用于「扫描后剥离」工作流(A3-11)
Sourcepub fn token_scan_pattern(&self, login_type: Option<&str>) -> String
pub fn token_scan_pattern(&self, login_type: Option<&str>) -> String
Glob pattern matching every token key (A3-11) | 匹配所有 token 键的 glob 模式(A3-11)
Sourcepub fn scan_pattern(&self, category: &str, login_type: Option<&str>) -> String
pub fn scan_pattern(&self, category: &str, login_type: Option<&str>) -> String
Glob pattern for any category (A3-11) | 任意分类的 glob 模式(A3-11)