pub struct AccessScope { /* private fields */ }Expand description
A disjunction (OR) of scope constraints defining what data is accessible.
Each constraint is an independent access path (OR-ed). Filters within a constraint are AND-ed. An unconstrained scope bypasses row-level filtering.
§Examples
use modkit_security::access_scope::{AccessScope, ScopeConstraint, ScopeFilter, pep_properties};
use uuid::Uuid;
// deny-all (default)
let scope = AccessScope::deny_all();
assert!(scope.is_deny_all());
// single tenant
let tid = Uuid::new_v4();
let scope = AccessScope::for_tenant(tid);
assert!(!scope.is_deny_all());
assert!(scope.contains_uuid(pep_properties::OWNER_TENANT_ID, tid));Implementations§
Source§impl AccessScope
impl AccessScope
Sourcepub fn from_constraints(constraints: Vec<ScopeConstraint>) -> AccessScope
pub fn from_constraints(constraints: Vec<ScopeConstraint>) -> AccessScope
Create an access scope from a list of constraints (OR-ed).
Sourcepub fn single(constraint: ScopeConstraint) -> AccessScope
pub fn single(constraint: ScopeConstraint) -> AccessScope
Create an access scope with a single constraint.
Sourcepub fn allow_all() -> AccessScope
pub fn allow_all() -> AccessScope
Create an “allow all” (unconstrained) scope.
This represents a legitimate PDP decision with no row-level filtering. Not a bypass — it’s a valid authorization outcome.
Sourcepub fn deny_all() -> AccessScope
pub fn deny_all() -> AccessScope
Create a “deny all” scope (no access).
Sourcepub fn for_tenants(ids: Vec<Uuid>) -> AccessScope
pub fn for_tenants(ids: Vec<Uuid>) -> AccessScope
Create a scope for a set of tenant IDs.
Sourcepub fn for_tenant(id: Uuid) -> AccessScope
pub fn for_tenant(id: Uuid) -> AccessScope
Create a scope for a single tenant ID.
Sourcepub fn for_resources(ids: Vec<Uuid>) -> AccessScope
pub fn for_resources(ids: Vec<Uuid>) -> AccessScope
Create a scope for a set of resource IDs.
Sourcepub fn for_resource(id: Uuid) -> AccessScope
pub fn for_resource(id: Uuid) -> AccessScope
Create a scope for a single resource ID.
Sourcepub fn constraints(&self) -> &[ScopeConstraint]
pub fn constraints(&self) -> &[ScopeConstraint]
The constraints in this scope (OR-ed).
Sourcepub fn is_unconstrained(&self) -> bool
pub fn is_unconstrained(&self) -> bool
Returns true if this scope is unconstrained (allow-all).
Sourcepub fn is_deny_all(&self) -> bool
pub fn is_deny_all(&self) -> bool
Returns true if this scope denies all access.
A scope is deny-all when it is not unconstrained and has no constraints.
Sourcepub fn all_values_for(&self, property: &str) -> Vec<&ScopeValue>
pub fn all_values_for(&self, property: &str) -> Vec<&ScopeValue>
Collect all values for a given property across all constraints.
Sourcepub fn all_uuid_values_for(&self, property: &str) -> Vec<Uuid>
pub fn all_uuid_values_for(&self, property: &str) -> Vec<Uuid>
Collect all UUID values for a given property across all constraints.
Convenience wrapper — skips non-UUID values.
Sourcepub fn contains_value(&self, property: &str, value: &ScopeValue) -> bool
pub fn contains_value(&self, property: &str, value: &ScopeValue) -> bool
Check if any constraint has a filter matching the given property and value.
Sourcepub fn contains_uuid(&self, property: &str, id: Uuid) -> bool
pub fn contains_uuid(&self, property: &str, id: Uuid) -> bool
Check if any constraint has a filter matching the given property and UUID.
Sourcepub fn has_property(&self, property: &str) -> bool
pub fn has_property(&self, property: &str) -> bool
Check if any constraint references the given property.
Trait Implementations§
Source§impl Clone for AccessScope
impl Clone for AccessScope
Source§fn clone(&self) -> AccessScope
fn clone(&self) -> AccessScope
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AccessScope
impl Debug for AccessScope
Source§impl Default for AccessScope
impl Default for AccessScope
Source§fn default() -> AccessScope
fn default() -> AccessScope
Default is deny-all: no constraints and not unconstrained.
Source§impl PartialEq for AccessScope
impl PartialEq for AccessScope
impl StructuralPartialEq for AccessScope
Auto Trait Implementations§
impl Freeze for AccessScope
impl RefUnwindSafe for AccessScope
impl Send for AccessScope
impl Sync for AccessScope
impl Unpin for AccessScope
impl UnsafeUnpin for AccessScope
impl UnwindSafe for AccessScope
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> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);