pub struct PermissionSet {
entries: Vec<PermissionEntry>,
sources: Vec<PermissionResolutionSource>,
}Expand description
A flat effective permission set with deterministic conflict resolution.
Fields§
§entries: Vec<PermissionEntry>§sources: Vec<PermissionResolutionSource>Implementations§
Source§impl PermissionSet
impl PermissionSet
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates an empty set. Unset permissions resolve to None and are denied by allows*.
Sourcepub fn from_entries(entries: impl IntoIterator<Item = PermissionEntry>) -> Self
pub fn from_entries(entries: impl IntoIterator<Item = PermissionEntry>) -> Self
Creates a set of direct subject rules.
Sourcepub fn entries(&self) -> &[PermissionEntry]
pub fn entries(&self) -> &[PermissionEntry]
Returns all rules in insertion order.
Sourcepub fn push(&mut self, entry: PermissionEntry)
pub fn push(&mut self, entry: PermissionEntry)
Adds a direct subject rule.
Sourcepub fn allow(&mut self, key: PermissionKey)
pub fn allow(&mut self, key: PermissionKey)
Adds a global direct allow.
Sourcepub fn allow_in(&mut self, key: PermissionKey, context: PermissionRuleContext)
pub fn allow_in(&mut self, key: PermissionKey, context: PermissionRuleContext)
Adds a contextual direct allow.
Sourcepub fn deny(&mut self, key: PermissionKey)
pub fn deny(&mut self, key: PermissionKey)
Adds a global direct deny.
Sourcepub fn deny_in(&mut self, key: PermissionKey, context: PermissionRuleContext)
pub fn deny_in(&mut self, key: PermissionKey, context: PermissionRuleContext)
Adds a contextual direct deny.
Sourcepub fn set(&mut self, key: PermissionKey, state: PermissionState)
pub fn set(&mut self, key: PermissionKey, state: PermissionState)
Replaces the exact global rule for key.
Sourcepub fn set_in(
&mut self,
key: PermissionKey,
context: PermissionRuleContext,
state: PermissionState,
)
pub fn set_in( &mut self, key: PermissionKey, context: PermissionRuleContext, state: PermissionState, )
Replaces the exact rule for key and context.
Sourcepub fn unset(&mut self, key: &PermissionKey) -> bool
pub fn unset(&mut self, key: &PermissionKey) -> bool
Removes the exact global rule for key.
Sourcepub fn unset_in(
&mut self,
key: &PermissionKey,
context: &PermissionRuleContext,
) -> bool
pub fn unset_in( &mut self, key: &PermissionKey, context: &PermissionRuleContext, ) -> bool
Removes the exact rule for key and context.
Sourcepub fn resolve_key(&self, key: &PermissionKey) -> Option<PermissionState>
pub fn resolve_key(&self, key: &PermissionKey) -> Option<PermissionState>
Resolves one key globally.
Sourcepub fn resolve_key_in(
&self,
key: &PermissionKey,
context: &PermissionContext,
) -> Option<PermissionState>
pub fn resolve_key_in( &self, key: &PermissionKey, context: &PermissionContext, ) -> Option<PermissionState>
Resolves one key in an active context.
Sourcepub fn resolve_key_detailed(
&self,
key: &PermissionKey,
) -> Option<PermissionResolution>
pub fn resolve_key_detailed( &self, key: &PermissionKey, ) -> Option<PermissionResolution>
Resolves one key globally and returns the winning rule details.
Sourcepub fn resolve_key_in_detailed(
&self,
key: &PermissionKey,
context: &PermissionContext,
) -> Option<PermissionResolution>
pub fn resolve_key_in_detailed( &self, key: &PermissionKey, context: &PermissionContext, ) -> Option<PermissionResolution>
Resolves one key in an active context and returns the winning rule details.
Sourcepub fn resolve_scoped_key(
&self,
parent: &PermissionKey,
key: &PermissionKey,
) -> Option<PermissionState>
pub fn resolve_scoped_key( &self, parent: &PermissionKey, key: &PermissionKey, ) -> Option<PermissionState>
Resolves a child key that may inherit a broad parent grant.
Sourcepub fn resolve_scoped_key_in(
&self,
parent: &PermissionKey,
key: &PermissionKey,
context: &PermissionContext,
) -> Option<PermissionState>
pub fn resolve_scoped_key_in( &self, parent: &PermissionKey, key: &PermissionKey, context: &PermissionContext, ) -> Option<PermissionState>
Resolves a child key with a parent fallback in an active context.
Sourcepub fn resolve_scoped_key_detailed(
&self,
parent: &PermissionKey,
key: &PermissionKey,
) -> Option<PermissionResolution>
pub fn resolve_scoped_key_detailed( &self, parent: &PermissionKey, key: &PermissionKey, ) -> Option<PermissionResolution>
Resolves a scoped child globally and returns the winning rule details.
Sourcepub fn resolve_scoped_key_in_detailed(
&self,
parent: &PermissionKey,
key: &PermissionKey,
context: &PermissionContext,
) -> Option<PermissionResolution>
pub fn resolve_scoped_key_in_detailed( &self, parent: &PermissionKey, key: &PermissionKey, context: &PermissionContext, ) -> Option<PermissionResolution>
Resolves a scoped child in an active context and returns winning rule details.
Sourcepub fn allows_key(&self, key: &PermissionKey) -> bool
pub fn allows_key(&self, key: &PermissionKey) -> bool
Returns whether one global key resolves to allow.
Sourcepub fn allows_key_in(
&self,
key: &PermissionKey,
context: &PermissionContext,
) -> bool
pub fn allows_key_in( &self, key: &PermissionKey, context: &PermissionContext, ) -> bool
Returns whether one key resolves to allow in context.
Sourcepub fn allows_scoped_key(
&self,
parent: &PermissionKey,
key: &PermissionKey,
) -> bool
pub fn allows_scoped_key( &self, parent: &PermissionKey, key: &PermissionKey, ) -> bool
Returns whether one scoped child resolves to allow globally.
Sourcepub fn allows_scoped_key_in(
&self,
parent: &PermissionKey,
key: &PermissionKey,
context: &PermissionContext,
) -> bool
pub fn allows_scoped_key_in( &self, parent: &PermissionKey, key: &PermissionKey, context: &PermissionContext, ) -> bool
Returns whether one scoped child resolves to allow in context.
Sourcepub fn allows(&self, permission: &PermissionExpr) -> bool
pub fn allows(&self, permission: &PermissionExpr) -> bool
Returns whether a global permission expression resolves to allow.
Sourcepub fn allows_in(
&self,
permission: &PermissionExpr,
context: &PermissionContext,
) -> bool
pub fn allows_in( &self, permission: &PermissionExpr, context: &PermissionContext, ) -> bool
Returns whether an expression resolves to allow in context.
Sourcepub fn resolve(&self, permission: &PermissionExpr) -> Option<PermissionState>
pub fn resolve(&self, permission: &PermissionExpr) -> Option<PermissionState>
Resolves a permission expression globally.
Sourcepub fn resolve_in(
&self,
permission: &PermissionExpr,
context: &PermissionContext,
) -> Option<PermissionState>
pub fn resolve_in( &self, permission: &PermissionExpr, context: &PermissionContext, ) -> Option<PermissionState>
Resolves a permission expression in context.
pub(super) fn push_group( &mut self, entry: PermissionEntry, group: &str, group_priority: i32, )
fn push_with_source( &mut self, entry: PermissionEntry, source: PermissionResolutionSource, )
fn retain_entries(&mut self, keep: impl FnMut(&PermissionEntry) -> bool)
fn best_key_candidate( &self, key: &PermissionKey, context: &PermissionContext, ) -> Option<PermissionCandidate>
fn best_scoped_key_candidate( &self, parent: &PermissionKey, key: &PermissionKey, context: &PermissionContext, ) -> Option<PermissionCandidate>
fn permission_resolution( &self, candidate: PermissionCandidate, ) -> PermissionResolution
Trait Implementations§
Source§impl Clone for PermissionSet
impl Clone for PermissionSet
Source§fn clone(&self) -> PermissionSet
fn clone(&self) -> PermissionSet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PermissionSet
impl Debug for PermissionSet
Source§impl Default for PermissionSet
impl Default for PermissionSet
Source§fn default() -> PermissionSet
fn default() -> PermissionSet
impl Eq for PermissionSet
Source§impl PartialEq for PermissionSet
impl PartialEq for PermissionSet
impl StructuralPartialEq for PermissionSet
Auto Trait Implementations§
impl Freeze for PermissionSet
impl RefUnwindSafe for PermissionSet
impl Send for PermissionSet
impl Sync for PermissionSet
impl Unpin for PermissionSet
impl UnsafeUnpin for PermissionSet
impl UnwindSafe for PermissionSet
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
self with key and returns true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 moreArc<SyncMutex<>>