pub struct Principal(/* private fields */);Expand description
An authenticated caller and the applications it may read.
Cheap to clone — a request handler carries one — because the grants are
behind an Arc rather than copied per request.
Implementations§
Source§impl Principal
impl Principal
Sourcepub fn new(
name: impl Into<String>,
applications: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn new( name: impl Into<String>, applications: impl IntoIterator<Item = impl Into<String>>, ) -> Self
A principal named name, granted applications.
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
The configured client name. Safe to log: it comes from the server’s own configuration, never from the request.
Sourcepub fn may_read(&self, application: &str) -> bool
pub fn may_read(&self, application: &str) -> bool
Whether this caller may read application.
Exact match, no wildcards and no prefixes. A grant language is a place to make a mistake that reads as a working deployment, and nothing here needs one.
Sourcepub fn applications(&self) -> &[String]
pub fn applications(&self) -> &[String]
The applications this caller may read.
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