From 3b059d1735b6d637a22bfffab358e002af69d1a6 Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Fri, 7 Jul 2017 23:24:37 -0700 Subject: [PATCH] Run rustfmt. --- src/api.rs | 10 +++++++--- src/lib.rs | 48 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/api.rs b/src/api.rs index 7568faaf..6677497a 100644 --- a/src/api.rs +++ b/src/api.rs @@ -10,9 +10,13 @@ pub mod unversioned { use {Client, Error}; /// Make a request to this API endpoint. - pub fn call<'a, C>(client: &'a Client, request: Request) - -> impl Future + 'a - where C: Connect { + pub fn call<'a, C>( + client: &'a Client, + request: Request, + ) -> impl Future + 'a + where + C: Connect, + { client.request::(request) } } diff --git a/src/lib.rs b/src/lib.rs index f171f476..e221c88c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,8 +6,10 @@ extern crate futures; extern crate hyper; -#[cfg(feature = "tls")] extern crate hyper_tls; -#[cfg(feature = "tls")] extern crate native_tls; +#[cfg(feature = "tls")] +extern crate hyper_tls; +#[cfg(feature = "tls")] +extern crate native_tls; extern crate ruma_api; extern crate ruma_client_api; extern crate ruma_identifiers; @@ -21,10 +23,12 @@ use std::convert::TryInto; use std::rc::Rc; use futures::future::{Future, FutureFrom, IntoFuture}; -use hyper::{Client as HyperClient}; +use hyper::Client as HyperClient; use hyper::client::{Connect, HttpConnector}; -#[cfg(feature = "hyper-tls")] use hyper_tls::HttpsConnector; -#[cfg(feature = "hyper-tls")] use native_tls::Error as NativeTlsError; +#[cfg(feature = "hyper-tls")] +use hyper_tls::HttpsConnector; +#[cfg(feature = "hyper-tls")] +use native_tls::Error as NativeTlsError; use ruma_api::Endpoint; use tokio_core::reactor::Handle; use url::Url; @@ -39,7 +43,10 @@ mod session; /// A client for the Matrix client-server API. #[derive(Debug)] -pub struct Client where C: Connect { +pub struct Client +where + C: Connect, +{ homeserver_url: Url, hyper: Rc>, session: Option, @@ -64,13 +71,21 @@ impl Client> { Ok(Client { homeserver_url, - hyper: Rc::new(HyperClient::configure().connector(connector).keep_alive(true).build(handle)), + hyper: Rc::new( + HyperClient::configure() + .connector(connector) + .keep_alive(true) + .build(handle), + ), session: None, }) } } -impl Client where C: Connect { +impl Client +where + C: Connect, +{ /// Creates a new client using the given `hyper::Client`. /// /// This allows the user to configure the details of HTTP as desired. @@ -83,16 +98,23 @@ impl Client where C: Connect { } /// Makes a request to a Matrix API endpoint. - pub(crate) fn request<'a, E>(&'a self, request: ::Request) - -> impl Future + 'a - where E: Endpoint, - ::Response: 'a { + pub(crate) fn request<'a, E>( + &'a self, + request: ::Request, + ) -> impl Future + 'a + where + E: Endpoint, + ::Response: 'a, + { request .try_into() .map_err(Error::from) .into_future() .and_then(move |hyper_request| { - self.hyper.clone().request(hyper_request).map_err(Error::from) + self.hyper + .clone() + .request(hyper_request) + .map_err(Error::from) }) .and_then(|hyper_response| { E::Response::future_from(hyper_response).map_err(Error::from)