rustfmt pass

master
Paul Woolcock 6 years ago
parent 49a2237803
commit 3330a26760
  1. 2
      examples/register.rs
  2. 2
      src/entities/itemsiter.rs
  3. 2
      src/http_send.rs
  4. 31
      src/lib.rs
  5. 22
      src/registration.rs

@ -6,9 +6,9 @@ use std::{error::Error, io};
use self::elefren::{
apps::{App, Scopes},
data::toml,
Mastodon,
Registration,
data::toml,
};
#[allow(dead_code)]

@ -1,5 +1,5 @@
use page::Page;
use http_send::HttpSend;
use page::Page;
use serde::Deserialize;
/// Abstracts away the `next_page` logic into a single stream of items

@ -1,5 +1,5 @@
use Result;
use reqwest::{Client, Request, RequestBuilder, Response};
use Result;
pub trait HttpSend {
fn execute(&self, client: &Client, request: Request) -> Result<Response>;

@ -49,13 +49,13 @@ use std::{borrow::Cow, ops};
use reqwest::{
header::{Authorization, Bearer, Headers},
Client,
Response,
RequestBuilder,
Response,
};
use entities::prelude::*;
use page::Page;
use http_send::{HttpSend, HttpSender};
use page::Page;
pub use data::Data;
pub use errors::{ApiError, Error, Result};
@ -265,10 +265,9 @@ impl<H: HttpSend> Mastodon<H> {
}
pub(crate) fn send(&self, req: &mut RequestBuilder) -> Result<Response> {
Ok(self.http_sender.send(
&self.client,
req.headers(self.headers.clone())
)?)
Ok(self
.http_sender
.send(&self.client, req.headers(self.headers.clone()))?)
}
}
@ -338,11 +337,7 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
fn update_credentials(&self, changes: CredientialsBuilder) -> Result<Account> {
let url = self.route("/api/v1/accounts/update_credentials");
let response = self.send(
self.client
.patch(&url)
.multipart(changes.into_form()?)
)?;
let response = self.send(self.client.patch(&url).multipart(changes.into_form()?))?;
let status = response.status().clone();
@ -360,7 +355,7 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
let response = self.send(
self.client
.post(&self.route("/api/v1/statuses"))
.json(&status)
.json(&status),
)?;
deserialise(response)
@ -441,9 +436,7 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
url = format!("{}{}", url, request.to_querystring());
}
let response = self.send(
&mut self.client.get(&url)
)?;
let response = self.send(&mut self.client.get(&url))?;
Page::new(self, response)
}
@ -465,9 +458,7 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
url.pop();
}
let response = self.send(
&mut self.client.get(&url)
)?;
let response = self.send(&mut self.client.get(&url))?;
Page::new(self, response)
}
@ -489,9 +480,7 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
following
);
let response = self.send(
&mut self.client.get(&url)
)?;
let response = self.send(&mut self.client.get(&url))?;
Page::new(self, response)
}

@ -2,12 +2,12 @@ use reqwest::{Client, RequestBuilder, Response};
use try_from::TryInto;
use apps::{App, Scopes};
use http_send::{HttpSend, HttpSender};
use Data;
use Error;
use Mastodon;
use MastodonBuilder;
use Result;
use http_send::{HttpSend, HttpSender};
/// Handles registering your mastodon app to your instance. It is recommended
/// you cache your data struct to avoid registering on every run.
@ -56,15 +56,12 @@ impl<H: HttpSend> Registration<H> {
Registration {
base: base.into(),
client: Client::new(),
http_sender: http_sender,
http_sender,
}
}
fn send(&self, req: &mut RequestBuilder) -> Result<Response> {
Ok(self.http_sender.send(
&self.client,
req
)?)
Ok(self.http_sender.send(&self.client, req)?)
}
/// Register the application with the server from the `base` url.
@ -96,9 +93,7 @@ impl<H: HttpSend> Registration<H> {
{
let app = app.try_into()?;
let url = format!("{}/api/v1/apps", self.base);
let oauth: OAuth = self.send(
self.client.post(&url).form(&app)
)?.json()?;
let oauth: OAuth = self.send(self.client.post(&url).form(&app))?.json()?;
Ok(Registered {
base: self.base,
@ -114,10 +109,7 @@ impl<H: HttpSend> Registration<H> {
impl<H: HttpSend> Registered<H> {
fn send(&self, req: &mut RequestBuilder) -> Result<Response> {
Ok(self.http_sender.send(
&self.client,
req
)?)
Ok(self.http_sender.send(&self.client, req)?)
}
/// Returns the full url needed for authorisation. This needs to be opened
@ -143,9 +135,7 @@ impl<H: HttpSend> Registered<H> {
self.redirect
);
let token: AccessToken = self.send(
&mut self.client.post(&url)
)?.json()?;
let token: AccessToken = self.send(&mut self.client.post(&url))?.json()?;
let data = Data {
base: self.base.into(),

Loading…
Cancel
Save