pub struct Permissions {
pub permissions: HashSet<Permission>,
pub user_permissions: HashMap<UserId, HashSet<Permission>>,
pub role_permissions: HashMap<String, HashSet<Permission>>,
pub user_roles: HashMap<UserId, HashSet<String>>,
}Expand description
多个权限对象
Fields§
§permissions: HashSet<Permission>所有权限种类
user_permissions: HashMap<UserId, HashSet<Permission>>用户分配的特别权限, Permitted表示拥有, Forbidden表示禁止
role_permissions: HashMap<String, HashSet<Permission>>某角色对权限的限制
user_roles: HashMap<UserId, HashSet<String>>用户被授权的角色
Trait Implementations§
Source§impl CandidType for Permissions
impl CandidType for Permissions
Source§impl Clone for Permissions
impl Clone for Permissions
Source§fn clone(&self) -> Permissions
fn clone(&self) -> Permissions
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 Permissions
impl Debug for Permissions
Source§impl Default for Permissions
impl Default for Permissions
Source§fn default() -> Permissions
fn default() -> Permissions
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for Permissions
impl<'de> Deserialize<'de> for Permissions
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Permissable<Permission> for Permissions
impl Permissable<Permission> for Permissions
Source§fn permission_users(&self) -> HashSet<&UserId>
fn permission_users(&self) -> HashSet<&UserId>
当前管理的所有用户 包括直接授权的和通过角色授权的
Source§fn permission_roles(&self) -> HashSet<&String>
fn permission_roles(&self) -> HashSet<&String>
当前管理的所有角色
Source§fn permission_assigned(&self, user_id: &UserId) -> Option<&HashSet<Permission>>
fn permission_assigned(&self, user_id: &UserId) -> Option<&HashSet<Permission>>
某用户被直接授权的权限
Source§fn permission_role_assigned(&self, role: &str) -> Option<&HashSet<Permission>>
fn permission_role_assigned(&self, role: &str) -> Option<&HashSet<Permission>>
某角色被直接授权的权限
Source§fn permission_has(&self, user_id: &UserId, permission: &Permission) -> bool
fn permission_has(&self, user_id: &UserId, permission: &Permission) -> bool
判断用户是否拥有某权限
Source§fn permission_owned(&self, user_id: &UserId) -> HashMap<&Permission, bool>
fn permission_owned(&self, user_id: &UserId) -> HashMap<&Permission, bool>
获取用户的综合权限情况
Source§fn permission_reset(&mut self, permissions: HashSet<Permission>)
fn permission_reset(&mut self, permissions: HashSet<Permission>)
重置管理的权限,防止版本更新导致某一个权限的信息不一致
Source§fn permission_update(
&mut self,
args: Vec<PermissionUpdatedArg<Permission>>,
) -> Result<(), PermissionUpdatedError<Permission>>
fn permission_update( &mut self, args: Vec<PermissionUpdatedArg<Permission>>, ) -> Result<(), PermissionUpdatedError<Permission>>
权限更新
Auto Trait Implementations§
impl Freeze for Permissions
impl RefUnwindSafe for Permissions
impl Send for Permissions
impl Sync for Permissions
impl Unpin for Permissions
impl UnsafeUnpin for Permissions
impl UnwindSafe for Permissions
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