pub struct AccessView { /* private fields */ }Expand description
An immutable per-request snapshot of one principal’s access.
Holds the config Arc taken at request start so a single request
evaluates against one consistent config, plus a handle to the shared
attribute cache for label/role lookups by identity.
Implementations§
Source§impl AccessView
impl AccessView
pub fn subject(&self) -> Option<&str>
pub fn groups(&self) -> &BTreeSet<String>
pub fn is_admin(&self) -> bool
Sourcepub fn decide(
&self,
action: &str,
resource: &AccessResource<'_>,
) -> AccessDecision
pub fn decide( &self, action: &str, resource: &AccessResource<'_>, ) -> AccessDecision
Full check against explicit resource attributes.
Sourcepub fn allows(&self, action: &str) -> bool
pub fn allows(&self, action: &str) -> bool
Check an action with no resource (e.g. gating.decide).
Sourcepub fn may_perform_anywhere(&self, action: &str) -> bool
pub fn may_perform_anywhere(&self, action: &str) -> bool
Coarse capability check: could this principal perform action against
at least one resource? Used to intersect capability advertisements
(mobkit/capabilities) so the console doesn’t surface affordances the
caller can never use; per-resource enforcement still applies per call.
Sourcepub fn allows_agent(&self, action: &str, identity: &str) -> bool
pub fn allows_agent(&self, action: &str, identity: &str) -> bool
Check an action against an agent identity, resolving cached attributes (role/labels) when available.
Sourcepub fn decide_agent(&self, action: &str, identity: &str) -> AccessDecision
pub fn decide_agent(&self, action: &str, identity: &str) -> AccessDecision
Full decision for an action against an agent identity, resolving cached attributes (role/labels) when available. The argument may also be a runtime agent/member id; the cache resolves it back to the identity it belongs to.
Agents carry their spawn lineage as a spawned_by label (recorded by
the agent-tool spawn path). A spawned member inherits its spawning
parent’s permissions: rules that match the parent — or any ancestor —
also match the member, with deny-overrides preserved across the chain.
Sourcepub fn can_view_agent(&self, identity: &str) -> bool
pub fn can_view_agent(&self, identity: &str) -> bool
Convenience: can this principal see the given agent at all?
Sourcepub fn knows_agent(&self, identity: &str) -> bool
pub fn knows_agent(&self, identity: &str) -> bool
True when the agent’s resource attributes (role/labels) are present in
the shared attribute cache, keyed by identity or projected agent_id.
A cache-MISS means decide_agent falls back to a bare-identity resource
with role: None, labels: None, so a label/role-scoped deny rule fails
the rule closed and DOES NOT match — i.e. the agent is not actually
hidden. Long-lived SSE streams use this to detect a member spawned after
the one-time subscribe prime and re-prime the cache before deciding, so
the deny resolves against real attributes instead of failing open.
Sourcepub fn can_administer(&self) -> bool
pub fn can_administer(&self) -> bool
Can this principal read and edit the access configuration?
Admins always can. While enforcement is enabled, subjects granted
access.admin by rule also can. While the feature is disabled and
no admins are configured yet, any caller can — this is the bootstrap
path that lets a fresh deployment configure itself from the console
before flipping enforcement on (enabling requires naming admins).
Trait Implementations§
Source§impl Clone for AccessView
impl Clone for AccessView
Source§fn clone(&self) -> AccessView
fn clone(&self) -> AccessView
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AccessView
impl RefUnwindSafe for AccessView
impl Send for AccessView
impl Sync for AccessView
impl Unpin for AccessView
impl UnsafeUnpin for AccessView
impl UnwindSafe for AccessView
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> 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 more