rustfmt pass

master
Paul Woolcock 6 years ago
parent 1436c28e42
commit c5788b8bd5
  1. 11
      examples/register.rs
  2. 4
      src/lib.rs
  3. 24
      src/registration.rs

@ -2,8 +2,7 @@
#![cfg_attr(not(feature = "toml"), allow(unused_imports))] #![cfg_attr(not(feature = "toml"), allow(unused_imports))]
extern crate elefren; extern crate elefren;
pub use self::elefren::prelude::*; pub use self::elefren::{apps::prelude::*, prelude::*};
pub use self::elefren::apps::prelude::*;
use std::{error::Error, io}; use std::{error::Error, io};
@ -31,10 +30,10 @@ pub fn get_mastodon_data() -> Result<Mastodon, Box<Error>> {
pub fn register() -> Result<Mastodon, Box<Error>> { pub fn register() -> Result<Mastodon, Box<Error>> {
let website = read_line("Please enter your mastodon instance url:")?; let website = read_line("Please enter your mastodon instance url:")?;
let registration = Registration::new(website.trim()) let registration = Registration::new(website.trim())
.client_name("elefren-examples") .client_name("elefren-examples")
.scopes(Scopes::All) .scopes(Scopes::All)
.website("https://github.com/pwoolcoc/elefren") .website("https://github.com/pwoolcoc/elefren")
.register()?; .register()?;
let url = registration.authorize_url()?; let url = registration.authorize_url()?;
println!("Click this link to authorize on Mastodon: {}", url); println!("Click this link to authorize on Mastodon: {}", url);

@ -12,8 +12,8 @@
//! use elefren::{apps::prelude::*, prelude::*}; //! use elefren::{apps::prelude::*, prelude::*};
//! //!
//! let registration = Registration::new("https://mastodon.social") //! let registration = Registration::new("https://mastodon.social")
//! .client_name("elefren_test") //! .client_name("elefren_test")
//! .register()?; //! .register()?;
//! let url = registration.authorize_url()?; //! let url = registration.authorize_url()?;
//! // Here you now need to open the url in the browser //! // Here you now need to open the url in the browser
//! // And handle a the redirect url coming back with the code. //! // And handle a the redirect url coming back with the code.

@ -4,7 +4,10 @@ use reqwest::{Client, RequestBuilder, Response};
use apps::{App, AppBuilder, Scopes}; use apps::{App, AppBuilder, Scopes};
use http_send::{HttpSend, HttpSender}; use http_send::{HttpSend, HttpSender};
use {Data, Mastodon, MastodonBuilder, Result}; use Data;
use Mastodon;
use MastodonBuilder;
use Result;
/// Handles registering your mastodon app to your instance. It is recommended /// Handles registering your mastodon app to your instance. It is recommended
/// you cache your data struct to avoid registering on every run. /// you cache your data struct to avoid registering on every run.
@ -92,8 +95,8 @@ impl<'a, H: HttpSend> Registration<'a, H> {
/// use elefren::{apps::prelude::*, prelude::*}; /// use elefren::{apps::prelude::*, prelude::*};
/// ///
/// let registration = Registration::new("https://mastodon.social") /// let registration = Registration::new("https://mastodon.social")
/// .client_name("elefren_test") /// .client_name("elefren_test")
/// .register()?; /// .register()?;
/// let url = registration.authorize_url()?; /// let url = registration.authorize_url()?;
/// // Here you now need to open the url in the browser /// // Here you now need to open the url in the browser
/// // And handle a the redirect url coming back with the code. /// // And handle a the redirect url coming back with the code.
@ -192,7 +195,10 @@ mod tests {
r.client_name("foo-test"); r.client_name("foo-test");
assert_eq!(r.base, "https://example.com".to_string()); assert_eq!(r.base, "https://example.com".to_string());
assert_eq!(&mut r.app_builder, AppBuilder::new().client_name("foo-test")); assert_eq!(
&mut r.app_builder,
AppBuilder::new().client_name("foo-test")
);
} }
#[test] #[test]
@ -201,7 +207,10 @@ mod tests {
r.redirect_uris("https://foo.com"); r.redirect_uris("https://foo.com");
assert_eq!(r.base, "https://example.com".to_string()); assert_eq!(r.base, "https://example.com".to_string());
assert_eq!(&mut r.app_builder, AppBuilder::new().redirect_uris("https://foo.com")); assert_eq!(
&mut r.app_builder,
AppBuilder::new().redirect_uris("https://foo.com")
);
} }
#[test] #[test]
@ -219,6 +228,9 @@ mod tests {
r.website("https://website.example.com"); r.website("https://website.example.com");
assert_eq!(r.base, "https://example.com".to_string()); assert_eq!(r.base, "https://example.com".to_string());
assert_eq!(&mut r.app_builder, AppBuilder::new().website("https://website.example.com")); assert_eq!(
&mut r.app_builder,
AppBuilder::new().website("https://website.example.com")
);
} }
} }

Loading…
Cancel
Save