summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Woolcock <paul@woolcock.us>2018-12-12 20:37:32 -0500
committerPaul Woolcock <paul@woolcock.us>2018-12-12 20:37:32 -0500
commitf12c0a4acb83722722520190913e4216d07d6603 (patch)
tree42bfab105e7912189d9c655116dcd4eeb6a9db08
parent4426bd647800013274f42ee2655cd555ddd2fa5b (diff)
Add `Registered::into_parts`
-rw-r--r--src/registration.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/registration.rs b/src/registration.rs
index 5859734..4836338 100644
--- a/src/registration.rs
+++ b/src/registration.rs
@@ -235,6 +235,38 @@ impl<H: HttpSend> Registered<H> {
Ok(self.http_sender.send(&self.client, req)?)
}
+ /// Returns the parts of the `Registered` struct that can be used to
+ /// recreate another `Registered` struct
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// # extern crate elefren;
+ /// use elefren::{prelude::*, registration::Registered};
+ /// # fn main() -> Result<(), Box<std::error::Error>> {
+ ///
+ /// let registered = Registered::from_parts(
+ /// "https://example.social",
+ /// "some-client-id",
+ /// "some-client-secret",
+ /// "https://example.social/redirect",
+ /// Scopes::all(),
+ /// );
+ ///
+ /// let (base, client_id, client_secret, redirect, scopes) = registered.into_parts();
+ /// # Ok(())
+ /// # }
+ /// ```
+ pub fn into_parts(self) -> (String, String, String, String, Scopes) {
+ (
+ self.base,
+ self.client_id,
+ self.client_secret,
+ self.redirect,
+ self.scopes,
+ )
+ }
+
/// Returns the full url needed for authorisation. This needs to be opened
/// in a browser.
pub fn authorize_url(&self) -> Result<String> {