pub struct Policy { /* private fields */ }Expand description
An immutable, compiled policy snapshot at one authz basis t.
Implementations§
Source§impl Policy
impl Policy
Sourcepub fn empty() -> Self
pub fn empty() -> Self
The empty policy at basis 0: no permission maps, so it denies everything. This is the fail-closed value, not a default to run on.
Sourcepub fn compile(db: &Db) -> Result<Self, PolicyError>
pub fn compile(db: &Db) -> Result<Self, PolicyError>
Compiles the policy recorded in db.
§Errors
Returns PolicyError when the snapshot is not an authz database or a
policy entity is malformed. Compilation is all-or-nothing on purpose: a
half-read policy would silently under- or over-grant.
Sourcepub const fn stats(&self) -> PolicyStats
pub const fn stats(&self) -> PolicyStats
Counts of the policy entities compiled.
Sourcepub fn principal(&self, id: &str) -> Option<&PrincipalDef>
pub fn principal(&self, id: &str) -> Option<&PrincipalDef>
The registration for id, when policy data names it.
Sourcepub fn objects_for_database(&self, name: &str) -> &[ObjectRef]
pub fn objects_for_database(&self, name: &str) -> &[ObjectRef]
Objects registered as standing for the Corium database name.
Sourcepub fn relations_for(
&self,
object_type: &str,
action: Action,
) -> BTreeSet<String>
pub fn relations_for( &self, object_type: &str, action: Action, ) -> BTreeSet<String>
Relations that satisfy action on an object of object_type.
Matching widens in three steps — the exact action name, then its class
(read/write/admin), then * — each against both the object’s own
type and *, so a policy can be as specific or as coarse as it likes.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Policy
impl !UnwindSafe for Policy
impl Freeze for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnsafeUnpin for Policy
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<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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request