Add missing pub(crate) statements.

This commit is contained in:
Yannick Heinrich
2018-10-05 13:46:38 +02:00
committed by Sean McArthur
parent 4857a5917d
commit 647f59756e
10 changed files with 39 additions and 57 deletions

View File

@@ -146,38 +146,36 @@ impl fmt::Debug for Chunk {
}
}
// pub(crate)
#[inline]
pub fn wrap(body: ::hyper::Body) -> Body {
pub(crate) fn wrap(body: ::hyper::Body) -> Body {
Body {
inner: Inner::Hyper(body),
}
}
#[inline]
pub fn empty() -> Body {
pub(crate) fn empty() -> Body {
Body {
inner: Inner::Hyper(::hyper::Body::empty()),
}
}
#[inline]
pub fn chunk(chunk: Bytes) -> Chunk {
pub(crate) fn chunk(chunk: Bytes) -> Chunk {
Chunk {
inner: ::hyper::Chunk::from(chunk)
}
}
#[inline]
pub fn reusable(chunk: Bytes) -> Body {
pub(crate) fn reusable(chunk: Bytes) -> Body {
Body {
inner: Inner::Reusable(chunk),
}
}
#[inline]
pub fn into_hyper(body: Body) -> (Option<Bytes>, ::hyper::Body) {
pub(crate) fn into_hyper(body: Body) -> (Option<Bytes>, ::hyper::Body) {
match body.inner {
Inner::Reusable(chunk) => (Some(chunk.clone()), chunk.into()),
Inner::Hyper(b) => (None, b),

View File

@@ -304,7 +304,7 @@ impl<R: Read> Read for Peeked<R> {
impl<S> ReadableChunks<S> {
#[inline]
pub fn new(stream: S) -> Self {
pub(crate) fn new(stream: S) -> Self {
ReadableChunks {
state: ReadState::NotReady,
stream: stream,
@@ -387,15 +387,13 @@ impl<S> ReadableChunks<S>
}
}
// pub(crate)
/// Constructs a Decoder from a hyper request.
///
/// A decoder is just a wrapper around the hyper request that knows
/// how to decode the content body of the request.
///
/// Uses the correct variant by inspecting the Content-Encoding header.
pub fn detect(headers: &mut HeaderMap, body: Body, check_gzip: bool) -> Decoder {
pub(crate) fn detect(headers: &mut HeaderMap, body: Body, check_gzip: bool) -> Decoder {
if !check_gzip {
return Decoder::plain_text(body);
}

View File

@@ -164,6 +164,7 @@ impl<T: Into<body::Body>> From<http::Response<T>> for Response {
}
}
/// A JSON object.
pub struct Json<T> {
concat: Concat2<Decoder>,
_marker: PhantomData<T>,

View File

@@ -8,7 +8,7 @@ use futures::future::{self, Either};
use futures::sync::{mpsc, oneshot};
use request::{Request, RequestBuilder};
use response::{self, Response};
use response::Response;
use {async_impl, header, Certificate, Identity, Method, IntoUrl, Proxy, RedirectPolicy, wait};
/// A `Client` to make Requests with.
@@ -500,7 +500,7 @@ impl ClientHandle {
}
};
res.map(|res| {
response::new(res, self.timeout.0, KeepCoreThreadAlive(Some(self.inner.clone())))
Response::new(res, self.timeout.0, KeepCoreThreadAlive(Some(self.inner.clone())))
})
}
}
@@ -515,9 +515,7 @@ impl Default for Timeout {
}
}
// pub(crate)
pub struct KeepCoreThreadAlive(Option<Arc<InnerClientHandle>>);
pub(crate) struct KeepCoreThreadAlive(Option<Arc<InnerClientHandle>>);
impl KeepCoreThreadAlive {
pub(crate) fn empty() -> KeepCoreThreadAlive {

View File

@@ -13,16 +13,14 @@ use std::sync::Arc;
use {proxy, Proxy};
// pub(crate)
pub struct Connector {
pub(crate) struct Connector {
https: HttpsConnector<HttpConnector>,
proxies: Arc<Vec<Proxy>>,
tls: TlsConnector,
}
impl Connector {
pub fn new(threads: usize, tls: TlsConnector, proxies: Arc<Vec<Proxy>>) -> Connector {
pub(crate) fn new(threads: usize, tls: TlsConnector, proxies: Arc<Vec<Proxy>>) -> Connector {
let mut http = HttpConnector::new(threads);
http.enforce_http(false);
let https = HttpsConnector::from((http, tls.clone()));
@@ -81,9 +79,9 @@ impl Connect for Connector {
type HttpStream = <HttpConnector as Connect>::Transport;
type HttpsStream = MaybeHttpsStream<HttpStream>;
pub type Connecting = Box<Future<Item=(Conn, Connected), Error=io::Error> + Send>;
pub(crate) type Connecting = Box<Future<Item=(Conn, Connected), Error=io::Error> + Send>;
pub enum Conn {
pub(crate) enum Conn {
Normal(HttpsStream),
Proxied(TlsStream<MaybeHttpsStream<HttpStream>>),
}

View File

@@ -9,8 +9,6 @@ pub trait IntoUrl: PolyfillTryInto {}
impl<T: PolyfillTryInto> IntoUrl for T {}
// pub(crate)
pub trait PolyfillTryInto {
// Besides parsing as a valid `Url`, the `Url` must be a valid
// `http::Uri`, in that it makes sense to use in a network request.

View File

@@ -180,11 +180,9 @@ impl fmt::Debug for Custom {
}
}
// pub(crate)
/// A helper trait to allow testing `Proxy::intercept` without having to
/// construct `hyper::client::connect::Destination`s.
trait Dst {
pub(crate) trait Dst {
fn scheme(&self) -> &str;
fn host(&self) -> &str;
fn port(&self) -> Option<u16>;
@@ -205,7 +203,7 @@ impl Dst for Destination {
}
}
pub fn intercept(proxy: &Proxy, uri: &Destination) -> Option<::http::Uri> {
pub(crate) fn intercept(proxy: &Proxy, uri: &Destination) -> Option<::http::Uri> {
proxy.intercept(uri)
}

View File

@@ -30,6 +30,21 @@ impl fmt::Debug for Response {
}
impl Response {
pub(crate) fn new(mut res: async_impl::Response, timeout: Option<Duration>, thread: KeepCoreThreadAlive) -> Response {
let body = mem::replace(res.body_mut(), async_impl::Decoder::empty());
let len = body.content_length();
let body = async_impl::ReadableChunks::new(WaitBody {
inner: wait::stream(body, timeout)
});
Response {
inner: res,
body: body,
content_length: len,
_thread_handle: thread,
}
}
/// Get the final `Url` of this `Response`.
///
/// # Example
@@ -320,26 +335,9 @@ impl Stream for WaitBody {
}
}
// pub(crate)
pub fn new(mut res: async_impl::Response, timeout: Option<Duration>, thread: KeepCoreThreadAlive) -> Response {
let body = mem::replace(res.body_mut(), async_impl::Decoder::empty());
let len = body.content_length();
let body = async_impl::ReadableChunks::new(WaitBody {
inner: wait::stream(body, timeout)
});
Response {
inner: res,
body: body,
content_length: len,
_thread_handle: thread,
}
}
impl<T: Into<async_impl::body::Body>> From<http::Response<T>> for Response {
fn from(r: http::Response<T>) -> Response {
let response = async_impl::Response::from(r);
new(response, None, KeepCoreThreadAlive::empty())
Response::new(response, None, KeepCoreThreadAlive::empty())
}
}

View File

@@ -113,12 +113,10 @@ impl fmt::Debug for Identity {
}
}
// pub(crate)
pub fn cert(cert: Certificate) -> native_tls::Certificate {
pub(crate) fn cert(cert: Certificate) -> native_tls::Certificate {
cert.0
}
pub fn pkcs12(identity: Identity) -> native_tls::Identity {
pub(crate) fn pkcs12(identity: Identity) -> native_tls::Identity {
identity.0
}

View File

@@ -5,10 +5,7 @@ use std::time::{Duration, Instant};
use futures::{Async, Future, Stream};
use futures::executor::{self, Notify};
// pub(crate)
pub fn timeout<F>(fut: F, timeout: Option<Duration>) -> Result<F::Item, Waited<F::Error>>
pub(crate) fn timeout<F>(fut: F, timeout: Option<Duration>) -> Result<F::Item, Waited<F::Error>>
where F: Future {
if let Some(dur) = timeout {
let start = Instant::now();
@@ -35,7 +32,7 @@ where F: Future {
}
}
pub fn stream<S>(stream: S, timeout: Option<Duration>) -> WaitStream<S>
pub(crate) fn stream<S>(stream: S, timeout: Option<Duration>) -> WaitStream<S>
where S: Stream {
WaitStream {
stream: executor::spawn(stream),
@@ -44,7 +41,7 @@ where S: Stream {
}
#[derive(Debug)]
pub enum Waited<E> {
pub(crate) enum Waited<E> {
TimedOut,
Err(E),
}
@@ -55,7 +52,7 @@ impl<E> From<E> for Waited<E> {
}
}
pub struct WaitStream<S> {
pub(crate) struct WaitStream<S> {
stream: executor::Spawn<S>,
timeout: Option<Duration>,
}