Check format to all rs files under src (#1188)

fixed-format of all missing files.
Fixes seanmonstar/reqwest#1186
This commit is contained in:
CfirTsabari
2021-03-02 03:06:14 +02:00
committed by GitHub
parent 9fa58e316d
commit a856638316
20 changed files with 336 additions and 306 deletions

View File

@@ -2,8 +2,8 @@
use super::multipart::Form;
/// dox
use bytes::Bytes;
use std::fmt;
use js_sys::Uint8Array;
use std::fmt;
use wasm_bindgen::JsValue;
/// The body of a `Request`.

View File

@@ -2,31 +2,26 @@ use wasm_bindgen::JsCast;
mod body;
mod client;
mod request;
mod response;
/// TODO
#[cfg(feature = "multipart")]
pub mod multipart;
mod request;
mod response;
pub use self::body::Body;
pub use self::client::{Client, ClientBuilder};
pub use self::request::{Request, RequestBuilder};
pub use self::response::Response;
async fn promise<T>(promise: js_sys::Promise) -> Result<T, crate::error::BoxError>
where
T: JsCast,
{
use wasm_bindgen_futures::JsFuture;
let js_val = JsFuture::from(promise)
.await
.map_err(crate::error::wasm)?;
let js_val = JsFuture::from(promise).await.map_err(crate::error::wasm)?;
js_val
.dyn_into::<T>()
.map_err(|_js_val| {
"promise resolved to unexpected type".into()
})
.map_err(|_js_val| "promise resolved to unexpected type".into())
}

View File

@@ -90,7 +90,6 @@ impl Form {
}
pub(crate) fn to_form_data(&self) -> crate::Result<FormData> {
let form = FormData::new()
.map_err(crate::error::wasm)
.map_err(crate::error::builder)?;

View File

@@ -2,11 +2,11 @@ use std::convert::TryFrom;
use std::fmt;
use http::{request::Parts, Method, Request as HttpRequest};
use url::Url;
use serde::Serialize;
#[cfg(feature = "json")]
use serde_json;
use serde::Serialize;
use serde_urlencoded;
use url::Url;
use super::{Body, Client, Response};
use crate::header::{HeaderMap, HeaderName, HeaderValue, CONTENT_TYPE};
@@ -184,7 +184,6 @@ impl RequestBuilder {
self.header(crate::header::AUTHORIZATION, header_value)
}
/// Set the request body.
pub fn body<T: Into<Body>>(mut self, body: T) -> RequestBuilder {
if let Ok(ref mut req) = self.request {

View File

@@ -1,8 +1,8 @@
use std::fmt;
use bytes::Bytes;
use js_sys::Uint8Array;
use http::{HeaderMap, StatusCode};
use js_sys::Uint8Array;
use url::Url;
#[cfg(feature = "json")]
@@ -17,10 +17,7 @@ pub struct Response {
}
impl Response {
pub(super) fn new(
res: http::Response<web_sys::Response>,
url: Url,
) -> Response {
pub(super) fn new(res: http::Response<web_sys::Response>, url: Url) -> Response {
Response {
http: res,
url: Box::new(url),
@@ -86,7 +83,10 @@ impl Response {
/// Get the response text.
pub async fn text(self) -> crate::Result<String> {
let p = self.http.body().text()
let p = self
.http
.body()
.text()
.map_err(crate::error::wasm)
.map_err(crate::error::decode)?;
let js_val = super::promise::<wasm_bindgen::JsValue>(p)
@@ -101,7 +101,10 @@ impl Response {
/// Get the response as bytes
pub async fn bytes(self) -> crate::Result<Bytes> {
let p = self.http.body().array_buffer()
let p = self
.http
.body()
.array_buffer()
.map_err(crate::error::wasm)
.map_err(crate::error::decode)?;