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) -> ScopeRef
pub fn parse(text: &str) -> ScopeRef
"*" → 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<ScopeRef, AddressError>
pub fn parse_checked(text: &str) -> Result<ScopeRef, 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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ScopeRef
impl<'de> Deserialize<'de> for ScopeRef
Source§fn deserialize<D>(d: D) -> Result<ScopeRef, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<ScopeRef, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
impl Eq for ScopeRef
Source§impl Ord for ScopeRef
impl Ord for ScopeRef
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for ScopeRef
impl PartialOrd for ScopeRef
Source§impl Serialize for ScopeRef
impl Serialize for ScopeRef
Source§fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for ScopeRef
Auto Trait Implementations§
impl Forget for ScopeRef
impl Freeze for ScopeRef
impl Move for ScopeRef
impl RefUnwindSafe for ScopeRef
impl Send for ScopeRef
impl Sync for ScopeRef
impl Unpin for ScopeRef
impl UnsafeUnpin for ScopeRef
impl UnwindSafe for ScopeRef
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.