about summary refs log tree commit diff
path: root/kittybox-rs/indieauth/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'kittybox-rs/indieauth/src/lib.rs')
-rw-r--r--kittybox-rs/indieauth/src/lib.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/kittybox-rs/indieauth/src/lib.rs b/kittybox-rs/indieauth/src/lib.rs
index 745ee1e..2cce1b9 100644
--- a/kittybox-rs/indieauth/src/lib.rs
+++ b/kittybox-rs/indieauth/src/lib.rs
@@ -70,6 +70,15 @@ pub enum ResponseType {
     /// requested.
     Code
 }
+// TODO serde_variant
+impl ResponseType {
+    /// Return the response type as it would appear in serialized form.
+    pub fn as_str(&self) -> &'static str {
+        match self {
+            ResponseType::Code => "code",
+        }
+    }
+}
 
 /// Grant types that are described in the IndieAuth spec.
 ///
@@ -252,6 +261,11 @@ impl State {
         Self(String::from_utf8(bytes).unwrap())
     }
 }
+impl AsRef<str> for State {
+    fn as_ref(&self) -> &str {
+        self.0.as_str()
+    }
+}
 
 /// The authorization request that should be affixed to the URL of an
 /// authorization endpoint to start the IndieAuth ceremony.