diff options
author | Ferris Tseng <ferris@navapbc.com> | 2019-12-24 13:08:56 -0500 |
---|---|---|
committer | Ferris Tseng <ferris@navapbc.com> | 2019-12-24 13:08:56 -0500 |
commit | 3d61a5f9c12962a3b62ee851905afdf980368a22 (patch) | |
tree | 7edd5b86effef20b247b97c1c7d0d9bbb0b67f1f | |
parent | cef3df9cd1958315dcc5cc4264a82e2574310330 (diff) |
move types to lib
-rw-r--r-- | ipfs-api/src/client.rs | 30 | ||||
-rw-r--r-- | ipfs-api/src/lib.rs | 32 |
2 files changed, 34 insertions, 28 deletions
diff --git a/ipfs-api/src/client.rs b/ipfs-api/src/client.rs index 880af32..f686b18 100644 --- a/ipfs-api/src/client.rs +++ b/ipfs-api/src/client.rs @@ -10,10 +10,9 @@ use crate::{ read::{JsonLineDecoder, LineDecoder, StreamReader}, request::{self, ApiRequest}, response::{self, Error}, + AsyncStreamResponse, Client, Request, Response, }; #[cfg(feature = "actix")] -use actix_http::{encoding, Payload, PayloadStream}; -#[cfg(feature = "actix")] use actix_multipart::client::multipart; use bytes::Bytes; use futures::{future, Future, FutureExt, Stream, TryFutureExt, TryStreamExt}; @@ -22,10 +21,7 @@ use http::{ StatusCode, }; #[cfg(feature = "hyper")] -use hyper::{ - body, - client::{self, Builder, HttpConnector}, -}; +use hyper::{body, client::Builder}; #[cfg(feature = "hyper")] use hyper_multipart::client::multipart; #[cfg(feature = "hyper")] @@ -41,28 +37,6 @@ use std::{ }; use tokio_util::codec::{Decoder, FramedRead}; -/// A future that returns a stream of responses. -/// -#[cfg(feature = "actix")] -type AsyncStreamResponse<T> = Box<dyn Stream<Item = Result<T, Error>> + Unpin + 'static>; -#[cfg(feature = "hyper")] -type AsyncStreamResponse<T> = Box<dyn Stream<Item = Result<T, Error>> + Unpin + Send + 'static>; - -#[cfg(feature = "actix")] -type Request = awc::ClientRequest; -#[cfg(feature = "hyper")] -type Request = http::Request<hyper::Body>; - -#[cfg(feature = "actix")] -type Response = awc::ClientResponse<encoding::Decoder<Payload<PayloadStream>>>; -#[cfg(feature = "hyper")] -type Response = http::Response<hyper::Body>; - -#[cfg(feature = "actix")] -type Client = awc::Client; -#[cfg(feature = "hyper")] -type Client = client::Client<HttpsConnector<HttpConnector>, hyper::Body>; - /// Asynchronous Ipfs client. /// #[derive(Clone)] diff --git a/ipfs-api/src/lib.rs b/ipfs-api/src/lib.rs index 3c638de..27cf2bf 100644 --- a/ipfs-api/src/lib.rs +++ b/ipfs-api/src/lib.rs @@ -168,3 +168,35 @@ mod header; mod read; mod request; pub mod response; + +#[cfg(feature = "actix")] +use actix_http::{encoding, Payload, PayloadStream}; +use futures::Stream; +#[cfg(feature = "hyper")] +use hyper::{self, client::HttpConnector}; +#[cfg(feature = "hyper")] +use hyper_tls::HttpsConnector; +use response::Error; + +/// A future that returns a stream of responses. +/// +#[cfg(feature = "actix")] +pub(crate) type AsyncStreamResponse<T> = Box<dyn Stream<Item = Result<T, Error>> + Unpin + 'static>; +#[cfg(feature = "hyper")] +pub(crate) type AsyncStreamResponse<T> = + Box<dyn Stream<Item = Result<T, Error>> + Unpin + Send + 'static>; + +#[cfg(feature = "actix")] +pub(crate) type Request = awc::ClientRequest; +#[cfg(feature = "hyper")] +pub(crate) type Request = http::Request<hyper::Body>; + +#[cfg(feature = "actix")] +pub(crate) type Response = awc::ClientResponse<encoding::Decoder<Payload<PayloadStream>>>; +#[cfg(feature = "hyper")] +pub(crate) type Response = http::Response<hyper::Body>; + +#[cfg(feature = "actix")] +pub(crate) type Client = awc::Client; +#[cfg(feature = "hyper")] +pub(crate) type Client = hyper::client::Client<HttpsConnector<HttpConnector>, hyper::Body>; |