diff options
author | Vika <vika@fireburn.ru> | 2022-09-19 17:08:01 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2022-09-19 17:08:01 +0300 |
commit | 696458657b26032e6e2a987c059fd69aaa10508d (patch) | |
tree | 57caa3e69a32756f1f5c075782a1abb3e4587d07 /kittybox-rs/indieauth/src/lib.rs | |
parent | 629531bdefad41e8839fa818e68bcf9a083466f8 (diff) | |
download | kittybox-696458657b26032e6e2a987c059fd69aaa10508d.tar.zst |
kittybox-indieauth: Allow converting more types to/from strings
Sometimes it is needed, for example, to construct an HTML form pre-filled with the request data.
Diffstat (limited to 'kittybox-rs/indieauth/src/lib.rs')
-rw-r--r-- | kittybox-rs/indieauth/src/lib.rs | 14 |
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. |