From f12c0a4acb83722722520190913e4216d07d6603 Mon Sep 17 00:00:00 2001 From: Paul Woolcock Date: Wed, 12 Dec 2018 20:37:32 -0500 Subject: [PATCH] Add `Registered::into_parts` --- src/registration.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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 Registered { 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> { + /// + /// 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 {