pub struct Scope(/* private fields */);Expand description
Atomic capability identifier, e.g. cone.send_message. Canonical
Scope newtype pinned by AUTHZ-S01-output §1. The grammar-validated
constructor (Scope::try_new), wildcard predicate (is_wildcard),
and segment-bounded matching (Scope::matches) live in
crate::scope_registry (AUTHZ-CORE-4). The macro-generated
Scope::new below stays unvalidated for wire-decoded values;
registry construction goes through try_new.
Implementations§
Source§impl Scope
impl Scope
Sourcepub fn try_new(s: impl Into<String>) -> Result<Self, ScopeError>
pub fn try_new(s: impl Into<String>) -> Result<Self, ScopeError>
Construct a Scope, validating the canonical grammar.
Accepts: bare *, dot-separated lowercase identifiers (each segment
[a-z][a-z0-9_]*), and an optional trailing .* segment wildcard.
Rejects everything else with a ScopeError carrying the offending
input.
Per AUTHZ-CORE-4. The pre-existing unvalidated Scope::new
constructor remains for wire-decoded values; registry construction
goes through this validating path.
Sourcepub fn is_wildcard(&self) -> bool
pub fn is_wildcard(&self) -> bool
True for the bare * and for any <prefix>.* form.
Sourcepub fn matches(&self, required: &Scope) -> bool
pub fn matches(&self, required: &Scope) -> bool
Does the holder of self satisfy the requirement required?
Returns true iff:
selfis the bare*(matches everything), ORself == required(exact match), ORselfends with.*AND its prefix-without-.*is a segment-prefix ofrequired.
Segment-prefix matching is the subtle case: cone.* matches
cone.send_message AND cone.threads.list (multiple downstream
segments) but does NOT match cone_extended.thing — the . boundary
is mandatory. A plain string-prefix check would silently match
cone_extended.thing; that is the exemplar trap AUTHZ-CORE-6’s
boundary test pins against.
The required side never carries wildcards in practice (a method’s
required scope is concrete); the holder side may. A required * is
only satisfied by a held * (via the bare-* arm).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Scope
impl<'de> Deserialize<'de> for Scope
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Scope
Source§impl JsonSchema for Scope
impl JsonSchema for Scope
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more