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

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]

pub fn new<I: Into<String>>(base: I) -> Self[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]

pub fn client_name<I: Into<Cow<'a, str>>>(&mut self, name: I) -> &mut Self[src]

Sets the name of this app

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

pub fn redirect_uris<I: Into<Cow<'a, str>>>(&mut self, uris: I) -> &mut Self[src]

Sets the redirect uris that this app uses

pub fn scopes(&mut self, scopes: Scopes) -> &mut Self[src]

Sets the scopes that this app requires

The default for an app is Scopes::Read

pub fn website<I: Into<Cow<'a, str>>>(&mut self, website: I) -> &mut Self[src]

Sets the optional "website" to register the app with

pub fn force_login(&mut self, force_login: bool) -> &mut Self[src]

Forces the user to re-login (useful if you need to re-auth as a different user on the same instance

pub fn register<I: TryInto<App>>(&mut self, app: I) -> Result<Registered<H>> where
    Error: From<<I as TryInto<App>>::Err>, 
[src]

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);

pub fn build(&mut self) -> Result<Registered<H>>[src]

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: Clone + HttpSend> Clone for Registration<'a, H>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

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

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

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Err = <U as TryFrom<T>>::Err