Skip to main content

SaKeys

Struct SaKeys 

Source
pub struct SaKeys { /* private fields */ }
Expand description

Storage key builder — the single source of truth for key schema 存储键构造器 —— 键 schema 的唯一来源

Implementations§

Source§

impl SaKeys

Source

pub fn new(prefix: impl AsRef<str>) -> Self

Creates a builder with the default SaKeyLayout::ThreeSegment layout 使用默认 SaKeyLayout::ThreeSegment 布局创建构造器

Source

pub fn with_layout(root: impl AsRef<str>, layout: SaKeyLayout) -> Self

Creates a builder with an explicit layout | 使用显式布局创建构造器

Source

pub fn from_config(config: &SaTokenConfig) -> Self

Builds from config, honouring key_layout (A3-1) | 从配置构建,遵循 key_layout(A3-1)

Source

pub fn prefix(&self) -> &str

Returns the key root | 返回键根

Source

pub fn layout(&self) -> SaKeyLayout

Returns the active layout | 返回生效的布局

Source

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)

Source

pub fn is_default_login_type(login_type: &str) -> bool

Returns true for login types normalized to the bare id 对归一为裸 id 的账号体系返回 true

Source

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)

Source

pub 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

Deprecated escape hatch kept for legacy call sites (A3-10) 为存量调用点保留的已弃用逃生舱(A3-10)

Source

pub fn token_info(&self, token: &str) -> String

Token → login_id mapping key | Token → login_id 映射键

Source

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)

Source

pub fn token_id_mapping(&self, token: &str) -> String

Reverse token → id mapping key (Rust-specific) | 反向 token → id 映射键(Rust 独有)

Source

pub fn token_session(&self, token: &str) -> String

Token-Session key | Token-Session 键

Source

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)

Source

pub fn last_active(&self, token: &str) -> String

Last-active timestamp key | 最后活跃时间键

Source

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)

Source

pub fn login_token(&self, login_type: &str, login_id: &str) -> String

login_id → token mapping key (Rust-specific) | login_id → token 映射键(Rust 独有)

Source

pub fn login_token_index(&self, login_type: &str, login_id: &str) -> String

Multi-device token index key (Rust-specific) | 多设备 token 索引键(Rust 独有)

Source

pub fn account_session(&self, login_type: &str, login_id: &str) -> String

Account-Session key | Account-Session 键

Source

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)

Source

pub fn permission(&self, login_type: &str, login_id: &str) -> String

Permission list key | 权限列表键

Source

pub fn role(&self, login_type: &str, login_id: &str) -> String

Role list key | 角色列表键

Source

pub fn disable(&self, login_type: &str, login_id: &str, service: &str) -> String

Account ban (disable) key | 账号封禁键

Source

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)

Source

pub fn safe(&self, token: &str, service: &str) -> String

Second-factor (safe) verification key | 二级认证键

Source

pub fn safe_with_type( &self, login_type: &str, token: &str, service: &str, ) -> String

Second-factor key for a specific account system | 指定账号体系的二级认证键

Source

pub fn nonce(&self, nonce_value: &str) -> String

Nonce replay-protection key | Nonce 防重放键

Source

pub fn refresh(&self, refresh_token: &str) -> String

Refresh token key | Refresh Token 键

Source

pub fn refresh_user_index(&self, login_type: &str, login_id: &str) -> String

Per-account refresh token index key | 按账号的 Refresh Token 索引键

Source

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)

Source

pub fn oauth2_client(&self, client_id: &str) -> String

OAuth2 client registration key | OAuth2 客户端注册键

Source

pub fn oauth2_code(&self, code: &str) -> String

OAuth2 authorization code key | OAuth2 授权码键

Source

pub fn oauth2_token(&self, access_token: &str) -> String

OAuth2 access token key | OAuth2 访问令牌键

Source

pub fn oauth2_refresh(&self, refresh_token: &str) -> String

OAuth2 refresh token key | OAuth2 刷新令牌键

Source

pub fn sso_ticket(&self, ticket_id: &str) -> String

SSO ticket key | SSO 票据键

Source

pub fn sso_session(&self, login_id: &str) -> String

SSO session key | SSO 会话键

Source

pub fn sso_login_token(&self, login_type: &str, login_id: &str) -> String

SSO login-token key | SSO 登录令牌键

Source

pub fn online(&self, login_id: &str, token: &str) -> String

Online-user record key | 在线用户记录键

Source

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)

Source

pub fn online_index(&self, login_id: &str) -> String

Online-user index key | 在线用户索引键

Source

pub fn online_index_with_type(&self, login_type: &str, login_id: &str) -> String

Online-user index key for a specific account system. 指定账号体系的在线用户索引键。

Source

pub fn online_users_set(&self) -> String

Global unique set of currently online login ids (list primitive). 当前在线账号 ID 的全局去重集合(走列表原语)。

Source

pub fn distributed_session(&self, session_id: &str) -> String

Distributed session key | 分布式会话键

Source

pub fn distributed_session_index(&self, login_id: &str) -> String

Distributed session index key | 分布式会话索引键

Source

pub fn distributed_service(&self, service_id: &str) -> String

Distributed service credential key | 分布式服务凭证键

Source

pub fn same_token(&self) -> String

Current Same-Token storage key. 当前 Same-Token 存储键。

Source

pub fn same_token_past(&self) -> String

Previous Same-Token storage key (grace window). 上一次 Same-Token 存储键(宽限期)。

Source

pub fn sign_nonce(&self, nonce: &str) -> String

Request-sign nonce occupancy key (not the login nonce space). 请求签名 nonce 占位键(与登录 nonce 键空间分离)。

Source

pub fn temp_token(&self, namespace: &str, token: &str) -> String

Temp-token body key. 临时令牌体键。

Source

pub fn temp_index(&self, namespace: &str, value_digest: &str) -> String

Temp-token reverse index (digest of the string value). 临时令牌反查索引(字符串 value 的摘要)。

Source

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)

Source

pub fn token_key_prefix(&self, login_type: Option<&str>) -> String

Token key prefix, for scan-and-strip workflows (A3-11) Token 键前缀,用于「扫描后剥离」工作流(A3-11)

Source

pub fn token_scan_pattern(&self, login_type: Option<&str>) -> String

Glob pattern matching every token key (A3-11) | 匹配所有 token 键的 glob 模式(A3-11)

Source

pub fn scan_pattern(&self, category: &str, login_type: Option<&str>) -> String

Glob pattern for any category (A3-11) | 任意分类的 glob 模式(A3-11)

Source

pub fn parse_token_from_key<'k>( &self, key: &'k str, login_type: Option<&str>, ) -> Option<&'k str>

Extracts the token value from a scanned token key (A3-12) 从扫描到的 token 键中提取 token 值(A3-12)

Source

pub fn parse_id_from_key<'k>( &self, key: &'k str, category: &str, login_type: Option<&str>, ) -> Option<&'k str>

Extracts the id segment from a scanned key of a given category (A3-12) 从扫描到的指定分类键中提取 id 段(A3-12)

Trait Implementations§

Source§

impl Clone for SaKeys

Source§

fn clone(&self) -> SaKeys

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SaKeys

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SaKeys

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ForyObject for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more