From c609e51712b287ba5f5c7bc8f142c63627e1caf8 Mon Sep 17 00:00:00 2001 From: Ferris Tseng Date: Sun, 4 Apr 2021 19:36:08 -0400 Subject: update ipfs-api to use re-export backend implementations --- ipfs-api/Cargo.toml | 51 +++++++++------------------------ ipfs-api/src/lib.rs | 81 +++++------------------------------------------------ 2 files changed, 20 insertions(+), 112 deletions(-) diff --git a/ipfs-api/Cargo.toml b/ipfs-api/Cargo.toml index 253d99d..92b16cc 100644 --- a/ipfs-api/Cargo.toml +++ b/ipfs-api/Cargo.toml @@ -7,52 +7,27 @@ documentation = "https://docs.rs/ipfs-api" repository = "https://github.com/ferristseng/rust-ipfs-api" keywords = ["ipfs"] categories = ["filesystem", "web-programming"] -version = "0.11.0" +version = "0.12.0" readme = "../README.md" license = "MIT OR Apache-2.0" [features] -default = ["with-hyper-tls", "with-builder"] -with-hyper-tls = ["with-hyper", "hyper-tls"] -with-hyper-rustls = ["with-hyper", "hyper-rustls"] -with-hyper = ["hyper", "hyper-multipart-rfc7578", "failure"] -with-actix = ["actix-http", "actix-multipart-rfc7578", "awc", "derive_more"] -with-builder = ["typed-builder"] +default = ["with-hyper", "with-builder"] +with-hyper-tls = ["with-hyper", "ipfs-api-backend-hyper/with-hyper-tls"] +with-hyper-rustls = ["with-hyper", "ipfs-api-backend-hyper/with-hyper-rustls"] +with-hyper = ["ipfs-api-backend-hyper"] +with-actix = ["ipfs-api-backend-actix"] +with-builder = ["ipfs-api-prelude/with-builder"] # Old features, kept for compatibility actix = ["with-actix"] builder = ["with-builder"] [dependencies] -actix-http = { version = "2.2", optional = true } -actix-multipart-rfc7578 = { version = "0.4", optional = true } -awc = { version = "2.0", optional = true } -bytes = "1.0" -derive_more = { version = "0.99", optional = true } -failure = { version = "0.1", optional = true } -futures = "0.3" -http = "0.2" -hyper = { version = "0.14", features = ["http1", "http2", "client"], optional = true } -hyper-tls = { version = "0.5", optional = true } -hyper-rustls = { version = "0.22", optional = true } -hyper-multipart-rfc7578 = { version = "0.5", optional = true } -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -serde_urlencoded = "0.7" -tokio = "1.2" -tokio-util = { version = "0.6", features = ["codec"] } -tracing = "0.1" -walkdir = "2.3" -dirs = "3.0" -parity-multiaddr = "0.11" -typed-builder = { version = "0.9", optional = true } +ipfs-api-prelude = { version = "0.1", path = "../ipfs-api-prelude" } +ipfs-api-backend-actix = { version = "0.1", path = "../ipfs-api-backend-actix", optional = true } +ipfs-api-backend-hyper = { version = "0.1", path = "../ipfs-api-backend-hyper", optional = true } [dev-dependencies] -actix-http = "2.2" -actix-rt = "1.0" -awc = "2.0" -hyper = "0.14" -hyper-tls = "0.5" -tar = "0.4" -tokio = { version = "1.2", features = ["rt-multi-thread", "macros", "time"] } -tokio-stream = { version = "0.1", features = ["time"] } -tracing-subscriber = { version = "0.2", features = ["fmt"] } +actix-rt = "2.0" +futures = "0.3" +tokio = { version = "1", features = ["rt-multi-thread", "macros"] } diff --git a/ipfs-api/src/lib.rs b/ipfs-api/src/lib.rs index 572e286..ac2932b 100644 --- a/ipfs-api/src/lib.rs +++ b/ipfs-api/src/lib.rs @@ -6,8 +6,6 @@ // copied, modified, or distributed except according to those terms. // -#![recursion_limit = "128"] - //! Rust library for connecting to the IPFS HTTP API using Hyper/Actix. //! //! ## Usage @@ -47,7 +45,7 @@ //! #### With Hyper //! //! ```no_run -//! use ipfs_api::IpfsClient; +//! use ipfs_api::{IpfsApi, IpfsClient}; //! use std::io::Cursor; //! //! #[tokio::main] @@ -65,7 +63,7 @@ //! #### With Actix //! //! ```no_run -//! use ipfs_api::IpfsClient; +//! use ipfs_api::{IpfsApi, IpfsClient}; //! use std::io::Cursor; //! //! #[actix_rt::main] @@ -86,7 +84,7 @@ //! //! ```no_run //! use futures::TryStreamExt; -//! use ipfs_api::IpfsClient; +//! use ipfs_api::{IpfsApi, IpfsClient}; //! use std::io::{self, Write}; //! //! #[tokio::main] @@ -114,7 +112,7 @@ //! //! ```no_run //! use futures::TryStreamExt; -//! use ipfs_api::IpfsClient; +//! use ipfs_api::{IpfsApi, IpfsClient}; //! use std::io::{self, Write}; //! //! #[actix_rt::main] @@ -156,78 +154,13 @@ //! ``` //! -#[cfg(feature = "with-actix")] -#[macro_use] -extern crate derive_more; - -#[cfg(feature = "with-hyper")] -#[macro_use] -extern crate failure; - -#[cfg(feature = "with-builder")] -#[macro_use] -extern crate typed_builder; - -extern crate serde; - -pub use crate::client::{IpfsClient, TryFromUri}; -pub use crate::request::{KeyType, Logger, LoggingLevel, ObjectTemplate}; - -mod client; -mod header; -mod read; -pub mod request; -pub mod response; - -// --- Hyper Connectors --- - -#[cfg(all(feature = "with-hyper-tls", not(feature = "with-hyper-rustls")))] -type HyperConnector = hyper_tls::HttpsConnector; -#[cfg(all(feature = "with-hyper-rustls", not(feature = "with-hyper-tls")))] -type HyperConnector = hyper_rustls::HttpsConnector; -#[cfg(all( - feature = "with-hyper", - any( - not(any(feature = "with-hyper-tls", feature = "with-hyper-rustls")), - all(feature = "with-hyper-rustls", feature = "with-hyper-tls"), - ) -))] -type HyperConnector = hyper::client::HttpConnector; - -// --- Multipart Crates --- - -#[cfg(feature = "with-actix")] -pub(crate) use actix_multipart_rfc7578::client::multipart; -#[cfg(feature = "with-hyper")] -pub(crate) use hyper_multipart_rfc7578::client::multipart; - -// --- Request Types --- - -#[cfg(feature = "with-actix")] -pub(crate) type Request = awc::SendClientRequest; -#[cfg(feature = "with-hyper")] -pub(crate) type Request = http::Request; +pub use ipfs_api_prelude::{self, IpfsApi, TryFromUri, response, request::{self, KeyType, Logger, LoggingLevel, ObjectTemplate}}; -// --- Response Types --- - -#[cfg(feature = "with-actix")] -pub(crate) type Response = awc::ClientResponse< - actix_http::encoding::Decoder>, ->; #[cfg(feature = "with-hyper")] -pub(crate) type Response = http::Response; - -// --- Client Types ---- +pub use ipfs_api_backend_hyper::IpfsClient; #[cfg(feature = "with-actix")] -pub(crate) type Client = awc::Client; -#[cfg(feature = "with-hyper")] -pub(crate) type Client = hyper::client::Client; - -// --- Validations --- - -#[cfg(all(feature = "with-hyper-rustls", feature = "with-hyper-tls"))] -compile_error!("Pick only one of the features: hyper-tls, hyper-rustls"); +pub use ipfs_api_backend_actix::IpfsClient; #[cfg(not(any(feature = "with-actix", feature = "with-hyper")))] compile_error!("Pick exactly one of these features: with-hyper, with-actix"); -- cgit v1.2.3