pub struct Subject { /* private fields */ }Expand description
A subject represents an entity that can be assigned roles (user, group, service, etc.).
Implementations§
Source§impl Subject
impl Subject
Sourcepub fn custom(id: impl Into<String>, custom_type: impl Into<String>) -> Self
pub fn custom(id: impl Into<String>, custom_type: impl Into<String>) -> Self
Create a new custom subject type.
Sourcepub fn subject_type(&self) -> &SubjectType
pub fn subject_type(&self) -> &SubjectType
Get the subject’s type.
Sourcepub fn with_display_name(self, display_name: impl Into<String>) -> Self
pub fn with_display_name(self, display_name: impl Into<String>) -> Self
Set the display name for the subject.
Sourcepub fn display_name(&self) -> Option<&str>
pub fn display_name(&self) -> Option<&str>
Get the subject’s display name.
Sourcepub fn set_display_name(&mut self, display_name: impl Into<String>)
pub fn set_display_name(&mut self, display_name: impl Into<String>)
Set the display name.
Sourcepub fn with_attribute(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_attribute( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add an attribute to the subject.
Sourcepub fn set_attribute(
&mut self,
key: impl Into<String>,
value: impl Into<String>,
)
pub fn set_attribute( &mut self, key: impl Into<String>, value: impl Into<String>, )
Set an attribute on the subject.
Sourcepub fn attributes(&self) -> &HashMap<String, String>
pub fn attributes(&self) -> &HashMap<String, String>
Get all attributes.
Sourcepub fn remove_attribute(&mut self, key: &str) -> Option<String>
pub fn remove_attribute(&mut self, key: &str) -> Option<String>
Remove an attribute.
Sourcepub fn has_attribute(&self, key: &str) -> bool
pub fn has_attribute(&self, key: &str) -> bool
Check if the subject has a specific attribute.
Sourcepub fn effective_name(&self) -> &str
pub fn effective_name(&self) -> &str
Get the effective name for display purposes.
Trait Implementations§
impl Eq for Subject
impl StructuralPartialEq for Subject
Auto Trait Implementations§
impl Freeze for Subject
impl RefUnwindSafe for Subject
impl Send for Subject
impl Sync for Subject
impl Unpin for Subject
impl UnwindSafe for Subject
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