Skip to main content

PermissionSet

Struct PermissionSet 

Source
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

Source

pub const fn new() -> Self

Creates an empty set. Unset permissions resolve to None and are denied by allows*.

Source

pub fn from_entries(entries: impl IntoIterator<Item = PermissionEntry>) -> Self

Creates a set of direct subject rules.

Source

pub fn entries(&self) -> &[PermissionEntry]

Returns all rules in insertion order.

Source

pub fn push(&mut self, entry: PermissionEntry)

Adds a direct subject rule.

Source

pub fn allow(&mut self, key: PermissionKey)

Adds a global direct allow.

Source

pub fn allow_in(&mut self, key: PermissionKey, context: PermissionRuleContext)

Adds a contextual direct allow.

Source

pub fn deny(&mut self, key: PermissionKey)

Adds a global direct deny.

Source

pub fn deny_in(&mut self, key: PermissionKey, context: PermissionRuleContext)

Adds a contextual direct deny.

Source

pub fn set(&mut self, key: PermissionKey, state: PermissionState)

Replaces the exact global rule for key.

Source

pub fn set_in( &mut self, key: PermissionKey, context: PermissionRuleContext, state: PermissionState, )

Replaces the exact rule for key and context.

Source

pub fn unset(&mut self, key: &PermissionKey) -> bool

Removes the exact global rule for key.

Source

pub fn unset_in( &mut self, key: &PermissionKey, context: &PermissionRuleContext, ) -> bool

Removes the exact rule for key and context.

Source

pub fn resolve_key(&self, key: &PermissionKey) -> Option<PermissionState>

Resolves one key globally.

Source

pub fn resolve_key_in( &self, key: &PermissionKey, context: &PermissionContext, ) -> Option<PermissionState>

Resolves one key in an active context.

Source

pub fn resolve_key_detailed( &self, key: &PermissionKey, ) -> Option<PermissionResolution>

Resolves one key globally and returns the winning rule details.

Source

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.

Source

pub fn resolve_scoped_key( &self, parent: &PermissionKey, key: &PermissionKey, ) -> Option<PermissionState>

Resolves a child key that may inherit a broad parent grant.

Source

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.

Source

pub fn resolve_scoped_key_detailed( &self, parent: &PermissionKey, key: &PermissionKey, ) -> Option<PermissionResolution>

Resolves a scoped child globally and returns the winning rule details.

Source

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.

Source

pub fn allows_key(&self, key: &PermissionKey) -> bool

Returns whether one global key resolves to allow.

Source

pub fn allows_key_in( &self, key: &PermissionKey, context: &PermissionContext, ) -> bool

Returns whether one key resolves to allow in context.

Source

pub fn allows_scoped_key( &self, parent: &PermissionKey, key: &PermissionKey, ) -> bool

Returns whether one scoped child resolves to allow globally.

Source

pub fn allows_scoped_key_in( &self, parent: &PermissionKey, key: &PermissionKey, context: &PermissionContext, ) -> bool

Returns whether one scoped child resolves to allow in context.

Source

pub fn allows(&self, permission: &PermissionExpr) -> bool

Returns whether a global permission expression resolves to allow.

Source

pub fn allows_in( &self, permission: &PermissionExpr, context: &PermissionContext, ) -> bool

Returns whether an expression resolves to allow in context.

Source

pub fn resolve(&self, permission: &PermissionExpr) -> Option<PermissionState>

Resolves a permission expression globally.

Source

pub fn resolve_in( &self, permission: &PermissionExpr, context: &PermissionContext, ) -> Option<PermissionState>

Resolves a permission expression in context.

Source

pub(super) fn push_group( &mut self, entry: PermissionEntry, group: &str, group_priority: i32, )

Source

fn push_with_source( &mut self, entry: PermissionEntry, source: PermissionResolutionSource, )

Source

fn retain_entries(&mut self, keep: impl FnMut(&PermissionEntry) -> bool)

Source

fn best_key_candidate( &self, key: &PermissionKey, context: &PermissionContext, ) -> Option<PermissionCandidate>

Source

fn best_scoped_key_candidate( &self, parent: &PermissionKey, key: &PermissionKey, context: &PermissionContext, ) -> Option<PermissionCandidate>

Source

fn permission_resolution( &self, candidate: PermissionCandidate, ) -> PermissionResolution

Trait Implementations§

Source§

impl Clone for PermissionSet

Source§

fn clone(&self) -> PermissionSet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PermissionSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PermissionSet

Source§

fn default() -> PermissionSet

Returns the “default value” for a type. Read more
Source§

impl Eq for PermissionSet

Source§

impl PartialEq for PermissionSet

Source§

fn eq(&self, other: &PermissionSet) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PermissionSet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compares self with key and returns true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoShared for T

Source§

fn into_shared(self) -> Arc<Mutex<RawMutex, Self>>

Wraps this value in an Arc<SyncMutex<>>
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more