Skip to main content

StpInterface

Trait StpInterface 

Source
pub trait StpInterface: Send + Sync {
    // Required methods
    fn get_permission_list<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        login_id: &'life1 str,
        login_type: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = SaTokenResult<Vec<String>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_role_list<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        login_id: &'life1 str,
        login_type: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = SaTokenResult<Vec<String>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided methods
    fn is_disabled<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        login_id: &'life1 str,
        service: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = SaTokenResult<Option<i32>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn is_writable(&self) -> bool { ... }
}
Expand description

权限、角色、封禁数据回调 | Permission, role and ban data callback

Required Methods§

Source

fn get_permission_list<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, login_id: &'life1 str, login_type: &'life2 str, ) -> Pin<Box<dyn Future<Output = SaTokenResult<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

返回账号在指定体系下的权限列表 | Permission list for the account in a login type

Source

fn get_role_list<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, login_id: &'life1 str, login_type: &'life2 str, ) -> Pin<Box<dyn Future<Output = SaTokenResult<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

返回账号在指定体系下的角色列表 | Role list for the account in a login type

Provided Methods§

Source

fn is_disabled<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, login_id: &'life1 str, service: &'life2 str, ) -> Pin<Box<dyn Future<Output = SaTokenResult<Option<i32>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

返回封禁等级;None 表示未封禁。

仅在 storage 中查不到封禁记录时才会被调用, 因此实现方无需关心与 storage 的优先级。

Ban level, None when not banned. Only consulted when storage has no ban record, so implementors need not reason about precedence.

Source

fn is_writable(&self) -> bool

本数据源是否接受框架发起的写入。

默认 false(只读),因为绝大多数自定义实现是「从既有权限系统读」, 把权限写回去需要额外的表结构与事务语义。返回 false 时,框架的 set_permissions / add_role 等写操作会按 crate::config::GrantWritePolicy 告警或拒绝, 避免写进一个自己永远读不到的地方。

内置的 StorageStpInterface 返回 true,因为它的读写同源。

Whether this data source accepts framework-issued writes. Defaults to false (read-only). The built-in StorageStpInterface returns true since its reads and writes share the same storage.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§