pub enum Scope {
Account(AccountScope),
Identity(IdentityScope),
Blob(BlobScope),
Repo(RepoScope),
Rpc(RpcScope),
Atproto,
Transition(TransitionScope),
OpenId,
Profile,
Email,
}Expand description
Represents an AT Protocol OAuth scope
Variants§
Account(AccountScope)
Account scope for accessing account information
Identity(IdentityScope)
Identity scope for accessing identity information
Blob(BlobScope)
Blob scope for blob operations with mime type constraints
Repo(RepoScope)
Repository scope for collection operations
Rpc(RpcScope)
RPC scope for method access
Atproto
AT Protocol scope - required to indicate that other AT Protocol scopes will be used
Transition(TransitionScope)
Transition scope for migration operations
OpenId
OpenID Connect scope - required for OpenID Connect authentication
Profile
Profile scope - access to user profile information
Email scope - access to user email address
Implementations§
Source§impl Scope
impl Scope
Sourcepub fn parse_multiple(s: &str) -> Result<Vec<Self>, ParseError>
pub fn parse_multiple(s: &str) -> Result<Vec<Self>, ParseError>
Parse multiple space-separated scopes from a string
§Examples
let scopes = Scope::parse_multiple("atproto repo:*").unwrap();
assert_eq!(scopes.len(), 2);Sourcepub fn parse_multiple_reduced(s: &str) -> Result<Vec<Self>, ParseError>
pub fn parse_multiple_reduced(s: &str) -> Result<Vec<Self>, ParseError>
Parse multiple space-separated scopes and return the minimal set needed
This method removes duplicate scopes and scopes that are already granted by other scopes in the list, returning only the minimal set of scopes needed.
§Examples
// repo:* grants repo:foo.bar, so only repo:* is kept
let scopes = Scope::parse_multiple_reduced("atproto repo:foo.bar repo:*").unwrap();
assert_eq!(scopes.len(), 2); // atproto and repo:*Sourcepub fn serialize_multiple(scopes: &[Self]) -> String
pub fn serialize_multiple(scopes: &[Self]) -> String
Serialize a list of scopes into a space-separated OAuth scopes string
The scopes are sorted alphabetically by their string representation to ensure consistent output regardless of input order.
§Examples
let scopes = vec![
Scope::parse("repo:*").unwrap(),
Scope::parse("atproto").unwrap(),
Scope::parse("account:email").unwrap(),
];
let result = Scope::serialize_multiple(&scopes);
assert_eq!(result, "account:email atproto repo:*");Sourcepub fn remove_scope(scopes: &[Self], scope_to_remove: &Self) -> Vec<Self>
pub fn remove_scope(scopes: &[Self], scope_to_remove: &Self) -> Vec<Self>
Remove a scope from a list of scopes
Returns a new vector with all instances of the specified scope removed. If the scope doesn’t exist in the list, returns a copy of the original list.
§Examples
let scopes = vec![
Scope::parse("repo:*").unwrap(),
Scope::parse("atproto").unwrap(),
Scope::parse("account:email").unwrap(),
];
let to_remove = Scope::parse("atproto").unwrap();
let result = Scope::remove_scope(&scopes, &to_remove);
assert_eq!(result.len(), 2);
assert!(!result.contains(&to_remove));Sourcepub fn parse(s: &str) -> Result<Self, ParseError>
pub fn parse(s: &str) -> Result<Self, ParseError>
Parse a scope from a string
Sourcepub fn to_string_normalized(&self) -> String
pub fn to_string_normalized(&self) -> String
Convert the scope to its normalized string representation
Trait Implementations§
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 UnwindSafe for Scope
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.