Skip to main content

Scope

Enum Scope 

Source
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: NsidPattern

The collection this scope covers, exact or wildcard.

§actions: ActionSet

Which write actions are covered.

§

Rpc

rpc:<lxm>[?aud=...].

Fields

§method: NsidPattern

The XRPC method this scope covers, exact or wildcard.

§aud: Option<String>

The audience this scope is bound to, percent-decoded: a DID, a DID and a service fragment, or * for every audience.

§

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: IdentityAttr

The part of the account’s identity this scope names.

§

Account

account:<attr>[?action=...]. Never granted either.

Fields

§attr: AccountAttr

The part of the account’s hosting this scope names.

§action: AccountAction

How 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: String

The set’s name, percent-decoded. crate::Include::new says whether it names a set at all.

§aud: Option<String>

The audience the set’s inheritAud permissions take, percent-decoded.

§

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

Source

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.

Source

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.

Source

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.

Source

pub fn repo_write(collection: &str, action: Action) -> Scope

The repo: scope one record write needs: action on exactly collection.

Source

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.

Source

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 Clone for Scope

Source§

fn clone(&self) -> Scope

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Scope

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Scope

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Ord for Scope

Source§

fn cmp(&self, other: &Scope) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Scope

Source§

fn eq(&self, other: &Scope) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Scope

Source§

fn partial_cmp(&self, other: &Scope) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for Scope

Source§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ToCowStr for T
where T: Display + ?Sized,

§

fn to_cowstr(&self) -> CowStr<'_>

Convert to a CowStr.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

§

fn to_smolstr(&self) -> SmolStr

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,