#[non_exhaustive]pub struct Permission {
pub code: String,
pub label: Text,
pub group: Text,
pub default_roles: Vec<String>,
pub renamed_from: Vec<String>,
}Expand description
A permission an operator can be granted: a dotted code, a human label,
and a group heading it sorts under in the role editor. The framework
registers its own (see the built-in grants), and an application registers
its permissions through router so they appear in the editor alongside.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.code: String§label: TextThe permission’s display label and group heading, localized at render.
group: Text§default_roles: Vec<String>The built-in roles that hold this permission. Empty means
ROLE_ADMIN alone.
renamed_from: Vec<String>Codes this permission used to have. At boot every role and override still holding one is rewritten to the current code.
Implementations§
Source§impl Permission
impl Permission
Sourcepub fn new(
code: impl Into<String>,
label: impl Into<Text>,
group: impl Into<Text>,
) -> Self
pub fn new( code: impl Into<String>, label: impl Into<Text>, group: impl Into<Text>, ) -> Self
A permission an operator can be granted, held by ROLE_ADMIN until it
names other roles with Permission::roles.
Sourcepub fn renamed_from<I, S>(self, codes: I) -> Self
pub fn renamed_from<I, S>(self, codes: I) -> Self
Codes this permission used to have.
A role or override still holding one is rewritten at the next boot, so a rename repairs what operators saved rather than leaving them granting a string nothing checks.
Sourcepub fn roles<I, S>(self, roles: I) -> Self
pub fn roles<I, S>(self, roles: I) -> Self
The built-in roles that hold this permission by default. Naming
ROLE_EDITOR alone keeps it out of ROLE_ADMIN.
Trait Implementations§
Source§impl Clone for Permission
impl Clone for Permission
Auto Trait Implementations§
impl Freeze for Permission
impl RefUnwindSafe for Permission
impl Send for Permission
impl Sync for Permission
impl Unpin for Permission
impl UnsafeUnpin for Permission
impl UnwindSafe for Permission
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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