From 11182edccf6b102e4def6671e8aa35e9402bd6f9 Mon Sep 17 00:00:00 2001 From: Emre Date: Thu, 23 Dec 2021 00:45:23 +0300 Subject: [PATCH] cargo fmt --- src/lib.rs | 37 ++++++++++++++++--------------------- src/params.rs | 7 +++++-- src/utils.rs | 2 +- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ff768ae..73610ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -use reqwest::{StatusCode}; +use reqwest::StatusCode; use serde::de::DeserializeOwned; use serde::Serialize; use serde_json::Value; @@ -6,10 +6,9 @@ use std::fmt::Debug; use url::Url; use constants::{Method, Response, AUTH}; -use errors::{RequestError, UrlParseError, UrlParseResult}; +use errors::{RequestError, RequestResult, UrlParseError, UrlParseResult}; use params::Params; use utils::check_uri; -use crate::errors::RequestResult; mod constants; mod errors; @@ -27,8 +26,8 @@ impl Firebase { // let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); /// ``` pub fn new(uri: &str) -> UrlParseResult - where - Self: Sized, + where + Self: Sized, { match check_uri(&uri) { Ok(uri) => Ok(Self { uri }), @@ -41,8 +40,8 @@ impl Firebase { // let firebase = Firebase::new("https://myfirebase.firebaseio.com").unwrap(); /// ``` pub fn auth(uri: &str, auth_key: &str) -> UrlParseResult - where - Self: Sized, + where + Self: Sized, { match check_uri(&uri) { Ok(mut uri) => { @@ -101,11 +100,7 @@ impl Firebase { self.uri.to_string() } - async fn request( - &self, - method: Method, - data: Option, - ) -> RequestResult { + async fn request(&self, method: Method, data: Option) -> RequestResult { let client = reqwest::Client::new(); return match method { @@ -171,8 +166,8 @@ impl Firebase { } async fn request_generic(&self, method: Method) -> RequestResult - where - T: Serialize + DeserializeOwned + Debug, + where + T: Serialize + DeserializeOwned + Debug, { let request = self.request(method, None).await; @@ -198,8 +193,8 @@ impl Firebase { // let users = firebase.set(&user).await; /// ``` pub async fn set(&self, data: &T) -> RequestResult - where - T: Serialize + DeserializeOwned + Debug, + where + T: Serialize + DeserializeOwned + Debug, { let data = serde_json::to_value(&data).unwrap(); self.request(Method::POST, Some(data)).await @@ -230,8 +225,8 @@ impl Firebase { // let user = firebase.get_generic::>().await; /// ``` pub async fn get(&self) -> RequestResult - where - T: Serialize + DeserializeOwned + Debug, + where + T: Serialize + DeserializeOwned + Debug, { self.request_generic::(Method::GET).await } @@ -257,8 +252,8 @@ impl Firebase { // let users = firebase.update(&user).await; /// ``` pub async fn update(&self, data: &T) -> RequestResult - where - T: DeserializeOwned + Serialize + Debug, + where + T: DeserializeOwned + Serialize + Debug, { let value = serde_json::to_value(&data).unwrap(); self.request(Method::PATCH, Some(value)).await @@ -296,4 +291,4 @@ mod tests { firebase.get_uri() ); } -} \ No newline at end of file +} diff --git a/src/params.rs b/src/params.rs index b2a6756..dfc1055 100644 --- a/src/params.rs +++ b/src/params.rs @@ -1,7 +1,7 @@ use crate::constants::{ END_AT, EQUAL_TO, EXPORT, FORMAT, LIMIT_TO_FIRST, LIMIT_TO_LAST, ORDER_BY, SHALLOW, START_AT, }; -use crate::{Firebase}; +use crate::Firebase; use std::collections::HashMap; use url::Url; @@ -24,7 +24,10 @@ impl Params { } } - pub fn add_param(&mut self, key: &str, value: T) -> &mut Self where T: ToString { + pub fn add_param(&mut self, key: &str, value: T) -> &mut Self + where + T: ToString, + { self.params.insert(key.to_string(), value.to_string()); self.set_params(); diff --git a/src/utils.rs b/src/utils.rs index 3d39eee..9ed4dcf 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,6 @@ -use url::Url; use crate::errors::UrlParseResult; use crate::UrlParseError; +use url::Url; pub fn check_uri(uri: &str) -> UrlParseResult { let uri = Url::parse(uri);