pub enum ScopeRef {
Everywhere,
Named(String),
}Expand description
Where a role is held: everywhere (*) or one named scope (MENGER).
What a name means — a shortcode, a tenant, a project — is the service’s;
the gate only compares names and asks Resolve::chain how they nest.
ONE-6: two kinds of name are not the service’s.
- A name that begins with
/is an address scope (/dyn,/dyn.*,ScopeRef::parse_checked), which the gate decides by the call’s address alone (CallAddress,DispatchedCall). It is never a data scope: a service whose own data scopes began with/loses them (as of 0.3.4), and aResolvechain that names one has it dropped. - The name
selfis reserved: written throughScopeRef::parse_checkedit is*; held as a rawNamed("self")(stored through the lenientScopeRef::parseor serde) it holds nothing at all — never a data scope, never*. AResolvechain that names it has it dropped too.
An address scope never stands for data: it opens the door of the calls
it covers and holds nothing else (the module’s “Activation scopes and
data scopes are separate”; the rules are Gate::as_data and
Gate::opens).
On the wire, a plain string: "*" or the name.
Variants§
Implementations§
Source§impl ScopeRef
impl ScopeRef
Sourcepub fn parse(text: &str) -> Self
pub fn parse(text: &str) -> Self
"*" → ScopeRef::Everywhere; anything else (trimmed) → named.
Lenient, as the wire is: it refuses nothing and reads self as a
name, which the gate then holds on nothing. A scope being written —
a membership granted (auth.grant, members.grant), a role or a
team’s grant stored, a ceiling minted into a session — must go
through ScopeRef::parse_checked, which reads self as * and
refuses a malformed address, so neither is stored to mean nothing.
Sourcepub fn is_everywhere(&self) -> bool
pub fn is_everywhere(&self) -> bool
Whether this is *.
Sourcepub fn parse_checked(text: &str) -> Result<Self, AddressError>
pub fn parse_checked(text: &str) -> Result<Self, AddressError>
ONE-6: a scope as a grant writes it, checked — what a membership or a ceiling may be held on:
*orself→ScopeRef::Everywhere: the root of the service being called (selfnever means the caller);/a.bor/a.b.*→ an address scope, kept as written (seeCallAddressfor the forms and what each covers); refused unless every segment is one or more ofA–Z a–z 0–9 _ -, so/,//,/*,/a.,/.a,/a..b,/a.*.b, and any*,@, space or non-ASCII character inside one are refused;- anything else non-empty, with no space around it → a data scope, the service’s own name.
ScopeRef::parse stays as it was (lenient, the wire’s): it never
reads self as *. A malformed address it lets through is held on
nothing — the gate reads every scope that begins with / as an
address scope or as nothing, never as a data scope.
Sourcepub fn is_address(&self) -> bool
pub fn is_address(&self) -> bool
ONE-6: whether this is an address scope — a name beginning with /.
Well formed or not: one that is not covers nothing.
Sourcepub fn covers_address(&self, at: &CallAddress) -> bool
pub fn covers_address(&self, at: &CallAddress) -> bool
ONE-6: whether this scope covers the call at at as an address:
* covers every call; /P the methods of the activation P and
the method P itself; /P.* the address P and everything under
it. A data scope, or a malformed address, covers none.