pub struct Principal { /* private fields */ }Expand description
A subject with assigned roles, direct grants/denials, and ABAC attributes.
Implementations§
Source§impl Principal
impl Principal
pub fn new(subject: impl Into<String>) -> Self
pub fn role(self, role: impl Into<String>) -> Self
Sourcepub fn allow(self, permission: impl AsRef<str>) -> Result<Self, RbacError>
pub fn allow(self, permission: impl AsRef<str>) -> Result<Self, RbacError>
§Errors
Returns an error for an invalid permission name.
Sourcepub fn deny(self, permission: impl AsRef<str>) -> Result<Self, RbacError>
pub fn deny(self, permission: impl AsRef<str>) -> Result<Self, RbacError>
Add an explicit subject-level denial. Explicit denial always wins.
§Errors
Returns an error for an invalid permission name.
pub fn attribute(self, name: impl Into<String>, value: impl Into<Value>) -> Self
pub fn subject(&self) -> &str
pub fn roles(&self) -> impl Iterator<Item = &str>
pub fn attribute_value(&self, name: &str) -> Option<&Value>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Principal
impl RefUnwindSafe for Principal
impl Send for Principal
impl Sync for Principal
impl Unpin for Principal
impl UnsafeUnpin for Principal
impl UnwindSafe for Principal
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