about summary refs log tree commit diff
path: root/indieauth/src
diff options
context:
space:
mode:
Diffstat (limited to 'indieauth/src')
-rw-r--r--indieauth/src/scopes.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/indieauth/src/scopes.rs b/indieauth/src/scopes.rs
index 295b0c8..7333b5b 100644
--- a/indieauth/src/scopes.rs
+++ b/indieauth/src/scopes.rs
@@ -111,6 +111,19 @@ impl Scopes {
     pub fn iter(&self) -> std::slice::Iter<'_, Scope> {
         self.0.iter()
     }
+
+    /// Count scopes requested by the application.
+    pub fn len(&self) -> usize {
+        self.0.len()
+    }
+
+    /// See if the application requested any scopes.
+    ///
+    /// Some older applications forget to request scopes. This may be used to force a default scope.
+    #[must_use]
+    pub fn is_empty(&self) -> bool {
+        self.len() == 0
+    }
 }
 impl AsRef<[Scope]> for Scopes {
     fn as_ref(&self) -> &[Scope] {