pub struct Ability { /* private fields */ }Expand description
Grants for a single role. Build with Ability::role then chain can*.
ⓘ
Ability::role("editor")
.can("update", "posts")
.can("publish", "posts") // a custom action, by name
.can_manage("comments"); // every action on commentsImplementations§
Source§impl Ability
impl Ability
Sourcepub fn role(name: impl Into<String>) -> Self
pub fn role(name: impl Into<String>) -> Self
Begin a grant set for role (the string stored in the admin user’s
role column and carried in the JWT).
Sourcepub fn can(self, action: impl Into<String>, resource: impl Into<String>) -> Self
pub fn can(self, action: impl Into<String>, resource: impl Into<String>) -> Self
Allow action on resource. action is a built-in token
(list/read/create/update/delete/export) or a custom action’s
name; resource is a resource’s base_path().
Sourcepub fn can_manage(self, resource: impl Into<String>) -> Self
pub fn can_manage(self, resource: impl Into<String>) -> Self
Allow every action on resource.
Sourcepub fn can_manage_all(self) -> Self
pub fn can_manage_all(self) -> Self
Allow every action on every resource (the superuser grant).
Sourcepub fn can_read_all(self) -> Self
pub fn can_read_all(self) -> Self
Allow read-only access everywhere: list, read, and export on every
resource. Handy for a “viewer” role.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Ability
impl RefUnwindSafe for Ability
impl Send for Ability
impl Sync for Ability
impl Unpin for Ability
impl UnsafeUnpin for Ability
impl UnwindSafe for Ability
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