#[non_exhaustive]pub enum Role {
SuperAdmin,
Admin,
Editor,
Viewer,
}Expand description
Framework-owned roles. #[non_exhaustive] because we may introduce
additional built-in tiers (e.g. Auditor) in a minor release;
downstream code must not rely on exhaustive matching.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SuperAdmin
Unrestricted access. The legacy "admin" role value resolves to
this tier for back-compat.
Admin
Full read/write on application models; view-only on framework
system tables (rustio_users, sessions, audit log).
Editor
View / create / edit on application models; no delete anywhere; view on system tables.
Viewer
View-only on every accessible model.
Implementations§
Source§impl Role
impl Role
Sourcepub fn from_role_string(s: &str) -> Option<Role>
pub fn from_role_string(s: &str) -> Option<Role>
Parse the stored rustio_users.role column value. Returns
None for values that grant no admin access (empty, "user",
or an unknown string). Case-insensitive; accepts a few
reasonable aliases (super_admin, super-admin).
Sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
Canonical wire string for the role, matching the values
Self::from_role_string produces. Note this is not
lossless with the legacy mapping — Role::SuperAdmin serialises
to "superadmin", while the legacy value "admin" also parses
back as Role::SuperAdmin.
Sourcepub fn display_name(self) -> &'static str
pub fn display_name(self) -> &'static str
Human-readable label for the role, suitable for rendering in the
admin header. Unlike Self::as_str, this is purely cosmetic.
Sourcepub fn permissions_for(self, model_table: &str) -> PermissionSet
pub fn permissions_for(self, model_table: &str) -> PermissionSet
Resolve the permission matrix for this role on a specific model
table. model_table is the raw SQL table name as it appears in
the schema (e.g. "posts", "rustio_users"). Unknown models
get the same defaults as any app table — the caller is
responsible for 404-ing models the schema doesn’t know about.
Sourcepub fn can(self, model_table: &str, action: Permission) -> bool
pub fn can(self, model_table: &str, action: Permission) -> bool
Shorthand for permissions_for(table).allows(action).
Trait Implementations§
impl Copy for Role
impl Eq for Role
impl StructuralPartialEq for Role
Auto Trait Implementations§
impl Freeze for Role
impl RefUnwindSafe for Role
impl Send for Role
impl Sync for Role
impl Unpin for Role
impl UnsafeUnpin for Role
impl UnwindSafe for Role
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more