From 3fbda4fd49f0ce525577e5fe131eeb9e22c1d414 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 15 Aug 2018 16:08:47 -0700 Subject: [PATCH] remove unstable language and feature --- Cargo.toml | 17 ----------------- examples/async.rs | 2 +- src/async_impl/body.rs | 9 --------- src/async_impl/client.rs | 8 +++----- src/async_impl/decoder.rs | 11 ++--------- src/async_impl/mod.rs | 2 -- src/async_impl/request.rs | 5 ++--- src/async_impl/response.rs | 14 +++----------- src/lib.rs | 37 ++++++++++++++----------------------- tests/async.rs | 4 +--- 10 files changed, 26 insertions(+), 83 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c5c718e..c1ec7b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,21 +38,4 @@ error-chain = "0.10" serde_derive = "1.0" [features] -unstable = [] - -[[example]] -name = "simple" -path = "examples/simple.rs" - -[[example]] -name = "form" -path = "examples/form.rs" - -[[example]] -name = "async" -path = "examples/async.rs" -required-features = ["unstable"] - -[package.metadata.docs.rs] -features = ["unstable"] diff --git a/examples/async.rs b/examples/async.rs index 70d5226..d35c31a 100644 --- a/examples/async.rs +++ b/examples/async.rs @@ -7,7 +7,7 @@ extern crate tokio; use std::mem; use std::io::{self, Cursor}; use futures::{Future, Stream}; -use reqwest::unstable::async::{Client, Decoder}; +use reqwest::async::{Client, Decoder}; fn fetch() -> impl Future { diff --git a/src/async_impl/body.rs b/src/async_impl/body.rs index a16426f..1ef76b3 100644 --- a/src/async_impl/body.rs +++ b/src/async_impl/body.rs @@ -141,15 +141,6 @@ pub fn wrap(body: ::hyper::Body) -> Body { } } -#[inline] -pub fn take(body: &mut Body) -> Body { - use std::mem; - let inner = mem::replace(&mut body.inner, Inner::Hyper(::hyper::Body::empty())); - Body { - inner: inner, - } -} - #[inline] pub fn empty() -> Body { Body { diff --git a/src/async_impl/client.rs b/src/async_impl/client.rs index 28e1de7..e390f95 100644 --- a/src/async_impl/client.rs +++ b/src/async_impl/client.rs @@ -17,7 +17,7 @@ use super::response::{self, Response}; use connect::Connector; use into_url::to_uri; use redirect::{self, RedirectPolicy, check_redirect, remove_sensitive_headers}; -use {Certificate, Identity, IntoUrl, Method, proxy, Proxy, StatusCode, Url}; +use {Certificate, Identity, IntoUrl, Method, Proxy, StatusCode, Url}; static DEFAULT_USER_AGENT: &'static str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); @@ -103,8 +103,8 @@ impl ClientBuilder { let proxies = Arc::new(config.proxies); - let mut connector = Connector::new(config.dns_threads, tls, proxies.clone()); - + let connector = Connector::new(config.dns_threads, tls, proxies.clone()); + let hyper_client = ::hyper::Client::builder() .build(connector); @@ -113,7 +113,6 @@ impl ClientBuilder { gzip: config.gzip, hyper: hyper_client, headers: config.headers, - proxies: proxies, redirect_policy: config.redirect_policy, referer: config.referer, }), @@ -449,7 +448,6 @@ struct ClientRef { gzip: bool, headers: HeaderMap, hyper: HyperClient, - proxies: Arc>, redirect_policy: RedirectPolicy, referer: bool, } diff --git a/src/async_impl/decoder.rs b/src/async_impl/decoder.rs index 1ffc8ed..c1f8250 100644 --- a/src/async_impl/decoder.rs +++ b/src/async_impl/decoder.rs @@ -25,19 +25,12 @@ use std::fmt; use std::mem; use std::cmp; use std::io::{self, Read}; -use std::marker::PhantomData; use bytes::{BufMut, BytesMut}; use libflate::non_blocking::gzip; -use tokio_io::AsyncRead; -use tokio_io::io as async_io; use futures::{Async, Future, Poll, Stream}; -use futures::stream::Concat2; -use hyper::{HeaderMap, StatusCode}; +use hyper::{HeaderMap}; use hyper::header::{CONTENT_ENCODING, CONTENT_LENGTH, TRANSFER_ENCODING, HeaderValue}; -use serde::de::DeserializeOwned; -use serde_json; -use url::Url; use super::{body, Body, Chunk}; use error; @@ -106,7 +99,7 @@ impl Decoder { /// /// This decoder will buffer and decompress chunks that are gzipped. #[inline] - fn gzip(mut body: Body) -> Decoder { + fn gzip(body: Body) -> Decoder { Decoder { inner: Inner::Pending(Pending::Gzip(ReadableChunks::new(body))) } diff --git a/src/async_impl/mod.rs b/src/async_impl/mod.rs index 309a672..5f71a97 100644 --- a/src/async_impl/mod.rs +++ b/src/async_impl/mod.rs @@ -1,5 +1,3 @@ -#![cfg_attr(not(features = "unstable"), allow(unused))] - pub use self::body::{Body, Chunk}; pub use self::decoder::{Decoder, ReadableChunks}; pub use self::client::{Client, ClientBuilder}; diff --git a/src/async_impl/request.rs b/src/async_impl/request.rs index 5953051..ef4d6b7 100644 --- a/src/async_impl/request.rs +++ b/src/async_impl/request.rs @@ -1,12 +1,11 @@ use std::fmt; use base64::{encode}; -use mime::{self}; use serde::Serialize; use serde_json; use serde_urlencoded; -use super::body::{self, Body}; +use super::body::{Body}; use super::client::{Client, Pending, pending_err}; use header::{CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue}; use http::HttpTryFrom; @@ -124,7 +123,7 @@ impl RequestBuilder { } /// Enable HTTP basic authentication. - pub fn basic_auth(mut self, username: U, password: Option

) -> RequestBuilder + pub fn basic_auth(self, username: U, password: Option

) -> RequestBuilder where U: fmt::Display, P: fmt::Display, diff --git a/src/async_impl/response.rs b/src/async_impl/response.rs index 14d7111..4b3a7b0 100644 --- a/src/async_impl/response.rs +++ b/src/async_impl/response.rs @@ -1,21 +1,15 @@ use std::fmt; use std::mem; -use std::io::{self, Read}; use std::marker::PhantomData; -use libflate::non_blocking::gzip; -use tokio_io::AsyncRead; -use tokio_io::io as async_io; use futures::{Async, Future, Poll, Stream}; use futures::stream::Concat2; -use hyper::{StatusCode, Version}; +use hyper::{HeaderMap, StatusCode, Version}; use serde::de::DeserializeOwned; use serde_json; use url::Url; -use hyper::header::{HeaderMap, CONTENT_ENCODING, CONTENT_LENGTH, TRANSFER_ENCODING}; -use super::{decoder, body, Body, Chunk, Decoder}; -use error; +use super::{decoder, body, Decoder}; /// A Response to a submitted `Request`. @@ -95,9 +89,7 @@ impl Response { /// # Example /// /// ``` - /// # #[cfg(feature="unstable")] - /// # use reqwest::unstable::async::Response; - /// # #[cfg(feature="unstable")] + /// # use reqwest::async::Response; /// fn on_response(res: Response) { /// match res.error_for_status() { /// Ok(_res) => (), diff --git a/src/lib.rs b/src/lib.rs index 6d62558..aed7345 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -187,30 +187,21 @@ mod wait; pub mod multipart; -/// A set of unstable functionality. +/// An 'async' implementation of the reqwest `Client`. /// -/// This module is only available when the `unstable` [feature][] is enabled. -/// There is no backwards compatibility guarantee for any of the types within. -/// -/// [feature]: http://doc.crates.io/specifying-dependencies.html#choosing-features -#[cfg(feature = "unstable")] -pub mod unstable { - /// An 'async' implementation of the reqwest `Client`. - /// - /// Relies on the `futures` crate, which is unstable, hence this module - /// is **unstable**. - pub mod async { - pub use ::async_impl::{ - Body, - Chunk, - Decoder, - Client, - ClientBuilder, - Request, - RequestBuilder, - Response, - }; - } +/// Relies on the `futures` crate, which is unstable, hence this module +/// is **unstable**. +pub mod async { + pub use ::async_impl::{ + Body, + Chunk, + Decoder, + Client, + ClientBuilder, + Request, + RequestBuilder, + Response, + }; } /// Shortcut method to quickly make a `GET` request. diff --git a/tests/async.rs b/tests/async.rs index c7aea0d..7b799aa 100644 --- a/tests/async.rs +++ b/tests/async.rs @@ -1,5 +1,3 @@ -#![cfg(feature="unstable")] - extern crate futures; extern crate libflate; extern crate reqwest; @@ -8,7 +6,7 @@ extern crate tokio; #[macro_use] mod support; -use reqwest::unstable::async::Client; +use reqwest::async::Client; use futures::{Future, Stream}; use std::io::Write; use std::time::Duration;