Struct elefren::registration::Registration[][src]

pub struct Registration<'a, H: HttpSend = HttpSender> { /* fields omitted */ }

Handles registering your mastodon app to your instance. It is recommended you cache your data struct to avoid registering on every run.

Methods

impl<'a> Registration<'a, HttpSender>
[src]

Construct a new registration process to the instance of the base url.

use elefren::prelude::*;

let registration = Registration::new("https://mastodon.social");

impl<'a, H: HttpSend> Registration<'a, H>
[src]

Important traits for &'a mut R

Sets the name of this app

This is required, and if this isn't set then the AppBuilder::build method will fail

Important traits for &'a mut R

Sets the redirect uris that this app uses

Important traits for &'a mut R

Sets the scopes that this app requires

The default for an app is Scopes::Read

Important traits for &'a mut R

Sets the optional "website" to register the app with

Register the given application

use elefren::{apps::App, prelude::*};

let mut app = App::builder();
app.client_name("elefren_test");

let registration = Registration::new("https://mastodon.social").register(app)?;
let url = registration.authorize_url()?;
// 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)?;

println!("{:?}", mastodon.get_home_timeline()?.initial_items);

Register the application with the server from the base url.

use elefren::prelude::*;

let registration = Registration::new("https://mastodon.social")
    .client_name("elefren_test")
    .build()?;
let url = registration.authorize_url()?;
// 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)?;

println!("{:?}", mastodon.get_home_timeline()?.initial_items);

Trait Implementations

impl<'a, H: Debug + HttpSend> Debug for Registration<'a, H>
[src]

Formats the value using the given formatter. Read more

impl<'a, H: Clone + HttpSend> Clone for Registration<'a, H>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<'a, H> Send for Registration<'a, H> where
    H: Send

impl<'a, H> Sync for Registration<'a, H> where
    H: Sync