pub struct Registered { /* private fields */ }Expand description
Represents the state of the auth flow when the app has been registered but the user is not authenticated
Implementations§
Source§impl Registered
impl Registered
Sourcepub fn from_parts(
base: &str,
client_id: &str,
client_secret: &str,
redirect: &str,
scopes: Scopes,
force_login: bool,
) -> Registered
pub fn from_parts( base: &str, client_id: &str, client_secret: &str, redirect: &str, scopes: Scopes, force_login: bool, ) -> Registered
Skip having to retrieve the client id and secret from the server by
creating a Registered struct directly
// Example
use mastodon_async::{prelude::*, registration::Registered};
tokio_test::block_on(async {
let registration = Registered::from_parts(
"https://example.com",
"the-client-id",
"the-client-secret",
"https://example.com/redirect",
Scopes::read_all(),
false,
);
let url = registration.authorize_url().unwrap();
// Here you now need to open the url in the browser
// And handle a the redirect url coming back with the code.
let code = String::from("RETURNED_FROM_BROWSER");
let mastodon = registration.complete(&code).await.unwrap();
println!("{:?}", mastodon.get_home_timeline().await.unwrap().initial_items);
});Source§impl Registered
impl Registered
Sourcepub fn into_parts(self) -> (String, String, String, String, Scopes, bool)
pub fn into_parts(self) -> (String, String, String, String, Scopes, bool)
Returns the parts of the Registered struct that can be used to
recreate another Registered struct
// Example
use mastodon_async::{prelude::*, registration::Registered};
let orig_base = "https://example.social";
let orig_client_id = "some-client_id";
let orig_client_secret = "some-client-secret";
let orig_redirect = "https://example.social/redirect";
let orig_scopes = Scopes::all();
let orig_force_login = false;
let registered = Registered::from_parts(
orig_base,
orig_client_id,
orig_client_secret,
orig_redirect,
orig_scopes.clone(),
orig_force_login,
);
let (base, client_id, client_secret, redirect, scopes, force_login) = registered.into_parts();
assert_eq!(orig_base, &base);
assert_eq!(orig_client_id, &client_id);
assert_eq!(orig_client_secret, &client_secret);
assert_eq!(orig_redirect, &redirect);
assert_eq!(orig_scopes, scopes);
assert_eq!(orig_force_login, force_login);Returns the full url needed for authorization. This needs to be opened in a browser.
Trait Implementations§
Source§impl Clone for Registered
impl Clone for Registered
Source§fn clone(&self) -> Registered
fn clone(&self) -> Registered
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for Registered
impl !UnwindSafe for Registered
impl Freeze for Registered
impl Send for Registered
impl Sync for Registered
impl Unpin for Registered
impl UnsafeUnpin for Registered
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more