pub enum Scope {
Atproto,
Transition(Transition),
Repo {
collection: NsidPattern,
actions: ActionSet,
},
Rpc {
method: NsidPattern,
aud: Option<String>,
},
Blob {
accept: Vec<MimePattern>,
},
Identity {
attr: IdentityAttr,
},
Account {
attr: AccountAttr,
action: AccountAction,
},
Include {
nsid: String,
aud: Option<String>,
},
Unknown(String),
}Expand description
One parsed scope atom.
Variants§
Atproto
The base atproto scope every grant carries.
Transition(Transition)
A legacy transition:* scope.
Repo
repo:<collection>[?action=...].
Fields
collection: NsidPatternThe collection this scope covers, exact or wildcard.
Rpc
rpc:<lxm>[?aud=...].
Fields
method: NsidPatternThe XRPC method this scope covers, exact or wildcard.
Blob
blob:<mime> or blob?accept=<mime>[&accept=<mime>…].
Fields
accept: Vec<MimePattern>The MIME types this scope covers, exact or wildcard. Sorted,
deduplicated, and never empty — see Scope::blob.
Identity
identity:<attr>. This server never grants one; see
plan/scope-policy.md.
Fields
attr: IdentityAttrThe part of the account’s identity this scope names.
Account
account:<attr>[?action=...]. Never granted either.
Fields
attr: AccountAttrThe part of the account’s hosting this scope names.
action: AccountActionHow much control over it this scope grants.
Include
include:<nsid>[?aud=...] — a permission set. As an atom it admits
only itself; crate::Include reads what it grants.
Fields
nsid: StringThe set’s name, percent-decoded. crate::Include::new says
whether it names a set at all.
Unknown(String)
An atom this grammar cannot read as any scope above: an unknown kind,
such as space:*, or a value its kind does not define, such as
account:status. Kept as written, it admits only itself.
Implementations§
Source§impl Scope
impl Scope
Sourcepub fn parse(atom: &str) -> Result<Scope, ScopeParseError>
pub fn parse(atom: &str) -> Result<Scope, ScopeParseError>
Parses an atom that names one scope, such as
repo:app.bsky.feed.post?action=create, whatever its form’s warnings.
An atom that lists several collections or methods names a scope for
each, and ScopeSet::parse is what reads
it. So does an atom this grammar cannot read, which
ScopeSet::parse keeps as
Scope::Unknown and this refuses.
Sourcepub fn contains(&self, other: &Scope) -> bool
pub fn contains(&self, other: &Scope) -> bool
Does self admit every request that other admits?
Reflexive and used both directions by ScopeSet::intersect: a
ceiling contains a requested scope, or a requested scope is itself a
(possibly equal) subset of the ceiling’s scope.
Sourcepub fn intersect(&self, other: &Scope) -> Option<Scope>
pub fn intersect(&self, other: &Scope) -> Option<Scope>
The most specific scope both self and other admit in common, if
their admitted requests overlap at all.
None is a real refusal, not an error: it means the two scopes name
disjoint capabilities (a repo: ceiling for one collection against a
request for a different one, say), and the caller — scope-policy’s
ceiling check — is expected to report that by name.
Sourcepub fn repo_write(collection: &str, action: Action) -> Scope
pub fn repo_write(collection: &str, action: Action) -> Scope
The repo: scope one record write needs: action on exactly
collection.
Sourcepub fn blob(accept: Vec<MimePattern>) -> Scope
pub fn blob(accept: Vec<MimePattern>) -> Scope
A blob: scope over accept, canonical: sorted, deduplicated, and
with any pattern another one already covers dropped, so
blob?accept=image/*&accept=image/png is blob:image/*.
§Panics
If accept is empty. Every caller builds it from something.
Sourcepub fn blob_upload(mime_type: &str) -> Scope
pub fn blob_upload(mime_type: &str) -> Scope
The blob: scope one upload needs: the type it declared.
The type is taken up to any ; — image/png; charset=binary is an
upload of image/png — and one that is not type/subtype at all is
taken as application/octet-stream, which is what an unreadable
content type means anyway.
Trait Implementations§
Source§impl Ord for Scope
impl Ord for Scope
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Scope
impl PartialOrd for Scope
impl Eq for Scope
impl StructuralPartialEq for Scope
Auto Trait Implementations§
impl Freeze for Scope
impl RefUnwindSafe for Scope
impl Send for Scope
impl Sync for Scope
impl Unpin for Scope
impl UnsafeUnpin for Scope
impl UnwindSafe for Scope
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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