pub struct Scopes { /* private fields */ }Expand description
A set of scopes, kept sorted so one set always renders identically.
OAuth writes scopes as a space-delimited string, which is easy to get wrong by hand — an empty scope, a double space, or a duplicate all produce a string that looks fine and compares unequal.
Implementations§
Source§impl Scopes
impl Scopes
pub fn new() -> Self
pub fn of<I, S>(scopes: I) -> Scopes
pub fn add(&mut self, scope: impl Into<String>)
pub fn with(self, scope: impl Into<String>) -> Self
pub fn contains(&self, scope: &str) -> bool
Sourcepub fn covers(&self, required: &Scopes) -> bool
pub fn covers(&self, required: &Scopes) -> bool
Whether this set covers everything required asks for.
The question an authorisation check actually asks: not “are these equal” but “is what I was granted enough”.
Sourcepub fn intersect(&self, allowed: &Scopes) -> Scopes
pub fn intersect(&self, allowed: &Scopes) -> Scopes
The scopes in this set that are also in allowed.
A client asking for more than it is registered for gets the intersection rather than a refusal, which is what most providers do — but the caller decides, because silently granting less than was asked for is worth knowing about.
Sourcepub fn beyond(&self, allowed: &Scopes) -> Scopes
pub fn beyond(&self, allowed: &Scopes) -> Scopes
Anything in this set that allowed does not contain.
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn iter(&self) -> impl Iterator<Item = &str>
Trait Implementations§
impl Eq for Scopes
impl StructuralPartialEq for Scopes
Auto Trait Implementations§
impl Freeze for Scopes
impl RefUnwindSafe for Scopes
impl Send for Scopes
impl Sync for Scopes
impl Unpin for Scopes
impl UnsafeUnpin for Scopes
impl UnwindSafe for Scopes
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
Mutably borrows from an owned value. Read more