summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Michaelis <gitter@liftm.de>2021-01-19 00:30:38 +0900
committerJulius Michaelis <gitter@liftm.de>2021-01-19 00:31:44 +0900
commitd53e6d335c3cfde51f6ceebd2da5306f5ed86ce8 (patch)
treec1a094f6fb6a0204ab22b286087832d4ffabada6
parentc465720a494312aea93aa87e16ff6baf25ef2e11 (diff)
Reorganize features
-rw-r--r--README.md2
-rw-r--r--ipfs-api/Cargo.toml12
-rw-r--r--ipfs-api/examples/add_file.rs4
-rw-r--r--ipfs-api/examples/add_tar.rs4
-rw-r--r--ipfs-api/examples/bootstrap_default.rs4
-rw-r--r--ipfs-api/examples/config.rs4
-rw-r--r--ipfs-api/examples/dag.rs4
-rw-r--r--ipfs-api/examples/dns.rs4
-rw-r--r--ipfs-api/examples/get_commands.rs4
-rw-r--r--ipfs-api/examples/get_stats.rs4
-rw-r--r--ipfs-api/examples/get_swarm.rs4
-rw-r--r--ipfs-api/examples/get_version.rs4
-rw-r--r--ipfs-api/examples/log_tail.rs4
-rw-r--r--ipfs-api/examples/mfs.rs4
-rw-r--r--ipfs-api/examples/ping_peer.rs4
-rw-r--r--ipfs-api/examples/pubsub.rs4
-rw-r--r--ipfs-api/examples/replace_config.rs4
-rw-r--r--ipfs-api/examples/resolve_name.rs4
-rw-r--r--ipfs-api/src/client/internal.rs66
-rw-r--r--ipfs-api/src/lib.rs43
-rw-r--r--ipfs-api/src/request/add.rs22
-rw-r--r--ipfs-api/src/request/files.rs60
-rw-r--r--ipfs-api/src/request/ls.rs8
-rw-r--r--ipfs-api/src/response/error.rs66
24 files changed, 176 insertions, 167 deletions
diff --git a/README.md b/README.md
index 0c71be8..baf10f9 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@ You can use `actix-web` as a backend instead of `hyper`.
```toml
[dependencies]
-ipfs-api = { version = "0.9.0", features = ["actix"], default-features = false }
+ipfs-api = { version = "0.9.0", features = ["with-actix"], default-features = false }
```
### Examples
diff --git a/ipfs-api/Cargo.toml b/ipfs-api/Cargo.toml
index 2fba349..1520c95 100644
--- a/ipfs-api/Cargo.toml
+++ b/ipfs-api/Cargo.toml
@@ -15,9 +15,15 @@ license = "MIT OR Apache-2.0"
travis-ci = { repository = "ferristseng/rust-ipfs-api" }
[features]
-default = ["hyper", "hyper-multipart-rfc7578", "hyper-tls", "failure"]
-actix = ["actix-http", "actix-multipart-rfc7578", "awc", "derive_more"]
-builder = ["typed-builder"]
+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"]
+# Old features, kept for compatibility
+actix = ["with-actix"]
+builder = ["with-builder"]
[dependencies]
actix-http = { version = "1.0", optional = true }
diff --git a/ipfs-api/examples/add_file.rs b/ipfs-api/examples/add_file.rs
index 3015684..5917884 100644
--- a/ipfs-api/examples/add_file.rs
+++ b/ipfs-api/examples/add_file.rs
@@ -11,8 +11,8 @@ use std::fs::File;
// Creates an Ipfs client, and adds this source file to Ipfs.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("note: this must be run in the root of the project repository");
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/examples/add_tar.rs b/ipfs-api/examples/add_tar.rs
index 0bf0eb9..a89c805 100644
--- a/ipfs-api/examples/add_tar.rs
+++ b/ipfs-api/examples/add_tar.rs
@@ -13,8 +13,8 @@ use tar::Builder;
// Creates an Ipfs client, and adds this source file to Ipfs.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("note: this must be run in the root of the project repository");
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/examples/bootstrap_default.rs b/ipfs-api/examples/bootstrap_default.rs
index 9377c49..8dc3772 100644
--- a/ipfs-api/examples/bootstrap_default.rs
+++ b/ipfs-api/examples/bootstrap_default.rs
@@ -11,8 +11,8 @@ use ipfs_api::IpfsClient;
// Lists clients in bootstrap list, then adds the default list, then removes
// them, and readds them.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/examples/config.rs b/ipfs-api/examples/config.rs
index 884ecb4..3964146 100644
--- a/ipfs-api/examples/config.rs
+++ b/ipfs-api/examples/config.rs
@@ -10,8 +10,8 @@ use ipfs_api::IpfsClient;
// Creates an Ipfs client, read & set config values.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("note: this must be run in the root of the project repository");
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/examples/dag.rs b/ipfs-api/examples/dag.rs
index 9dff2bb..20d7bef 100644
--- a/ipfs-api/examples/dag.rs
+++ b/ipfs-api/examples/dag.rs
@@ -12,8 +12,8 @@ use std::io::Cursor;
// Creates an Ipfs client, and adds this dag object to Ipfs then fetch it back.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("note: this must be run in the root of the project repository");
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/examples/dns.rs b/ipfs-api/examples/dns.rs
index 02857e0..a9b0604 100644
--- a/ipfs-api/examples/dns.rs
+++ b/ipfs-api/examples/dns.rs
@@ -10,8 +10,8 @@ use ipfs_api::IpfsClient;
// Creates an Ipfs client, resolves ipfs.io, and lists the contents of it.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/examples/get_commands.rs b/ipfs-api/examples/get_commands.rs
index 4aa91ce..5ca7b00 100644
--- a/ipfs-api/examples/get_commands.rs
+++ b/ipfs-api/examples/get_commands.rs
@@ -32,8 +32,8 @@ fn print_recursive(indent: usize, cmd: &response::CommandsResponse) {
// Creates an Ipfs client, and gets a list of available commands from the
// Ipfs server.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/examples/get_stats.rs b/ipfs-api/examples/get_stats.rs
index f6eef0f..c2b6835 100644
--- a/ipfs-api/examples/get_stats.rs
+++ b/ipfs-api/examples/get_stats.rs
@@ -10,8 +10,8 @@ use ipfs_api::IpfsClient;
// Creates an Ipfs client, and gets some stats about the Ipfs server.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/examples/get_swarm.rs b/ipfs-api/examples/get_swarm.rs
index 67dc70b..114f70e 100644
--- a/ipfs-api/examples/get_swarm.rs
+++ b/ipfs-api/examples/get_swarm.rs
@@ -11,8 +11,8 @@ use ipfs_api::IpfsClient;
// Creates an Ipfs client, and gets information about your local address, and
// connected peers.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/examples/get_version.rs b/ipfs-api/examples/get_version.rs
index 9d22988..bc91f50 100644
--- a/ipfs-api/examples/get_version.rs
+++ b/ipfs-api/examples/get_version.rs
@@ -10,8 +10,8 @@ use ipfs_api::IpfsClient;
// Creates an Ipfs client, and gets the version of the Ipfs server.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/examples/log_tail.rs b/ipfs-api/examples/log_tail.rs
index 79b6e65..2e4955a 100644
--- a/ipfs-api/examples/log_tail.rs
+++ b/ipfs-api/examples/log_tail.rs
@@ -11,8 +11,8 @@ use ipfs_api::IpfsClient;
// Tails the log of IPFS.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/examples/mfs.rs b/ipfs-api/examples/mfs.rs
index 3d6419c..85dd0f7 100644
--- a/ipfs-api/examples/mfs.rs
+++ b/ipfs-api/examples/mfs.rs
@@ -20,8 +20,8 @@ fn print_stat(stat: response::FilesStatResponse) {
// Creates an Ipfs client, and makes some calls to the Mfs Api.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("note: this must be run in the root of the project repository");
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/examples/ping_peer.rs b/ipfs-api/examples/ping_peer.rs
index 2934c16..08b0496 100644
--- a/ipfs-api/examples/ping_peer.rs
+++ b/ipfs-api/examples/ping_peer.rs
@@ -12,8 +12,8 @@ use ipfs_api::{response::PingResponse, IpfsClient};
// Creates an Ipfs client, discovers a connected peer, and pings it using the
// streaming Api, and by collecting it into a collection.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/examples/pubsub.rs b/ipfs-api/examples/pubsub.rs
index 465b86b..6fef446 100644
--- a/ipfs-api/examples/pubsub.rs
+++ b/ipfs-api/examples/pubsub.rs
@@ -25,8 +25,8 @@ fn get_client() -> IpfsClient {
// Creates an Ipfs client, and simultaneously publishes and reads from a pubsub
// topic.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("note: ipfs must be run with the --enable-pubsub-experiment flag");
diff --git a/ipfs-api/examples/replace_config.rs b/ipfs-api/examples/replace_config.rs
index 76cc96f..372609b 100644
--- a/ipfs-api/examples/replace_config.rs
+++ b/ipfs-api/examples/replace_config.rs
@@ -11,8 +11,8 @@ use std::io::Cursor;
// Creates an Ipfs client, and replaces the config file with the default one.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("note: this must be run in the root of the project repository");
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/examples/resolve_name.rs b/ipfs-api/examples/resolve_name.rs
index 0d7b830..57ad10e 100644
--- a/ipfs-api/examples/resolve_name.rs
+++ b/ipfs-api/examples/resolve_name.rs
@@ -13,8 +13,8 @@ const IPFS_IPNS: &str = "/ipns/ipfs.io";
// Creates an Ipfs client, and resolves the Ipfs domain name, and
// publishes a path to Ipns.
//
-#[cfg_attr(feature = "actix", actix_rt::main)]
-#[cfg_attr(feature = "hyper", tokio::main)]
+#[cfg_attr(feature = "with-actix", actix_rt::main)]
+#[cfg_attr(feature = "with-hyper", tokio::main)]
async fn main() {
eprintln!("connecting to localhost:5001...");
diff --git a/ipfs-api/src/client/internal.rs b/ipfs-api/src/client/internal.rs
index c94ecb7..9b07572 100644
--- a/ipfs-api/src/client/internal.rs
+++ b/ipfs-api/src/client/internal.rs
@@ -13,7 +13,7 @@ use crate::{
response::{self, Error},
Client, Request, Response,
};
-#[cfg(feature = "actix")]
+#[cfg(feature = "with-actix")]
use actix_multipart::client::multipart;
use bytes::Bytes;
use futures::{future, FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt};
@@ -21,16 +21,16 @@ use http::{
uri::{Scheme, Uri},
StatusCode,
};
-#[cfg(feature = "hyper")]
+#[cfg(feature = "with-hyper")]
use hyper::{body, client::Builder};
-#[cfg(feature = "hyper")]
+#[cfg(feature = "with-hyper")]
use hyper_multipart::client::multipart;
-#[cfg(feature = "hyper")]
+#[cfg(feature = "with-hyper")]
use crate::HyperConnector;
use serde::{Deserialize, Serialize};
use serde_json;
-#[cfg(feature = "actix")]
+#[cfg(feature = "with-actix")]
use std::time::Duration;
use std::{
fs::File,
@@ -45,7 +45,7 @@ fn default<T: Default>() -> T {
const FILE_DESCRIPTOR_LIMIT: usize = 127;
-#[cfg(feature = "actix")]
+#[cfg(feature = "with-actix")]
const ACTIX_REQUEST_TIMEOUT: Duration = Duration::from_secs(90);
/// Asynchronous Ipfs client.
@@ -61,13 +61,13 @@ impl TryFromUri for IpfsClient {
///
fn build_with_base_uri(uri: Uri) -> IpfsClient {
let client = {
- #[cfg(feature = "hyper")]
+ #[cfg(feature = "with-hyper")]
{
Builder::default()
.pool_max_idle_per_host(0)
.build(HyperConnector::new())
}
- #[cfg(feature = "actix")]
+ #[cfg(feature = "with-actix")]
{
Client::default()
}
@@ -105,7 +105,7 @@ impl IpfsClient {
::serde_urlencoded::to_string(req)?
);
- #[cfg(feature = "hyper")]
+ #[cfg(feature = "with-hyper")]
{
url.parse::<Uri>().map_err(From::from).and_then(move |url| {
let builder = http::Request::builder().method(http::Method::POST).uri(url);
@@ -119,7 +119,7 @@ impl IpfsClient {
req.map_err(From::from)
})
}
- #[cfg(feature = "actix")]
+ #[cfg(feature = "with-actix")]
{
let req = if let Some(form) = form {
self.client
@@ -171,11 +171,11 @@ impl IpfsClient {
where
D: Decoder<Item = Res, Error = Error> + Send,
{
- #[cfg(feature = "hyper")]
+ #[cfg(feature = "with-hyper")]
{
FramedRead::new(StreamReader::new(res.into_body()), decoder)
}
- #[cfg(feature = "actix")]
+ #[cfg(feature = "with-actix")]
{
FramedRead::new(StreamReader::new(res), decoder)
}
@@ -193,7 +193,7 @@ impl IpfsClient {
{
let req = self.build_base_request(req, form)?;
- #[cfg(feature = "hyper")]
+ #[cfg(feature = "with-hyper")]
{
let res = self.client.request(req).await?;
let status = res.status();
@@ -201,7 +201,7 @@ impl IpfsClient {
Ok((status, body))
}
- #[cfg(feature = "actix")]
+ #[cfg(feature = "with-actix")]
{
let mut res = req.await?;
let status = res.status();
@@ -280,7 +280,7 @@ impl IpfsClient {
OutStream: Stream<Item = Result<Res, Error>>,
F: 'static + Fn(Response) -> OutStream,
{
- #[cfg(feature = "hyper")]
+ #[cfg(feature = "with-hyper")]
{
self.client
.request(req)
@@ -304,7 +304,7 @@ impl IpfsClient {
})
.try_flatten_stream()
}
- #[cfg(feature = "actix")]
+ #[cfg(feature = "with-actix")]
{
req.err_into()
.map_ok(move |mut res| {
@@ -332,11 +332,11 @@ impl IpfsClient {
/// back a raw stream of bytes.
///
fn request_stream_bytes(&self, req: Request) -> impl Stream<Item = Result<Bytes, Error>> {
- #[cfg(feature = "hyper")]
+ #[cfg(feature = "with-hyper")]
{
self.request_stream(req, |res| res.into_body().err_into())
}
- #[cfg(feature = "actix")]
+ #[cfg(feature = "with-actix")]
{
self.request_stream(req, |res| res.err_into())
}
@@ -433,11 +433,11 @@ impl IpfsClient {
/// # fn main() {
/// let client = IpfsClient::default();
/// let data = Cursor::new("Hello World!");
- /// #[cfg(feature = "builder")]
+ /// #[cfg(feature = "with-builder")]
/// let add = ipfs_api::request::Add::builder()
/// .chunker("rabin-512-1024-2048")
/// .build();
- /// #[cfg(not(feature = "builder"))]
+ /// #[cfg(not(feature = "with-builder"))]
/// let add = ipfs_api::request::Add {
/// chunker: Some("rabin-512-1024-2048"),
/// ..Default::default()
@@ -1324,13 +1324,13 @@ impl IpfsClient {
///
/// ```no_run
/// let client = ipfs_api::IpfsClient::default();
- /// #[cfg(feature = "builder")]
+ /// #[cfg(feature = "with-builder")]
/// let req = ipfs_api::request::FilesLs::builder()
/// // .path("/") // defaults to /
/// .unsorted(false)
/// .long(true)
/// .build();
- /// #[cfg(not(feature = "builder"))]
+ /// #[cfg(not(feature = "with-builder"))]
/// let req = ipfs_api::request::FilesLs {
/// path: None, // defaults to /
/// unsorted: Some(false),
@@ -1379,13 +1379,13 @@ impl IpfsClient {
/// use ipfs_api::IpfsClient;
///
/// let client = IpfsClient::default();
- /// #[cfg(feature = "builder")]
+ /// #[cfg(feature = "with-builder")]
/// let req = ipfs_api::request::FilesMkdir::builder()
/// .path("/test/nested/dir")
/// .parents(true)
/// .flush(false)
/// .build();
- /// #[cfg(not(feature = "builder"))]
+ /// #[cfg(not(feature = "with-builder"))]
/// let req = ipfs_api::request::FilesMkdir {
/// path: "/test/nested/dir",
/// parents: Some(true),
@@ -1472,13 +1472,13 @@ impl IpfsClient {
/// use ipfs_api::IpfsClient;
///
/// let client = IpfsClient::default();
- /// #[cfg(feature = "builder")]
+ /// #[cfg(feature = "with-builder")]
/// let req = ipfs_api::request::FilesRead::builder()
/// .path("/test/file.json")
/// .offset(1024)
/// .count(8)
/// .build();
- /// #[cfg(not(feature = "builder"))]
+ /// #[cfg(not(feature = "with-builder"))]
/// let req = ipfs_api::request::FilesRead {
/// path: "/test/file.json",
/// offset: Some(1024),
@@ -1525,13 +1525,13 @@ impl IpfsClient {
/// use ipfs_api::IpfsClient;
///
/// let client = IpfsClient::default();
- /// #[cfg(feature = "builder")]
+ /// #[cfg(feature = "with-builder")]
/// let req = ipfs_api::request::FilesRm::builder()
/// .path("/test/somefile.json")
/// .recursive(false)
/// .flush(false)
/// .build();
- /// #[cfg(not(feature = "builder"))]
+ /// #[cfg(not(feature = "with-builder"))]
/// let req = ipfs_api::request::FilesRm {
/// path: "/test/somefile.json",
/// recursive: Some(false),
@@ -1621,7 +1621,7 @@ impl IpfsClient {
/// ```no_run
/// let client = ipfs_api::IpfsClient::default();
/// let data = std::io::Cursor::new((1..128).collect::<Vec<u8>>());
- /// #[cfg(feature = "builder")]
+ /// #[cfg(feature = "with-builder")]
/// let req = ipfs_api::request::FilesWrite::builder()
/// .path("/test/outfile.bin")
/// .create(false)
@@ -1630,7 +1630,7 @@ impl IpfsClient {
/// .flush(false)
/// // see FilesWriteBuilder for the full set of options
/// .build();
- /// #[cfg(not(feature = "builder"))]
+ /// #[cfg(not(feature = "with-builder"))]
/// let req = ipfs_api::request::FilesWrite {
/// path: "/test/outfile.bin",
/// create: Some(false),
@@ -1694,14 +1694,14 @@ impl IpfsClient {
/// use std::fs::File;
///
/// let client = IpfsClient::default();
- /// #[cfg(feature = "builder")]
+ /// #[cfg(feature = "with-builder")]
/// let req = ipfs_api::request::FilesChcid::builder()
/// .path("/test/")
/// .cid_version(1)
/// .hash("sha3-512")
/// .flush(true)
/// .build();
- /// #[cfg(not(feature = "builder"))]
+ /// #[cfg(not(feature = "with-builder"))]
/// let req = ipfs_api::request::FilesChcid {
/// path: Some("/test/"),
/// cid_version: Some(1),
@@ -1964,7 +1964,7 @@ impl IpfsClient {
/// use ipfs_api::IpfsClient;
///
/// let client = IpfsClient::default();
- /// #[cfg(feature = "builder")]
+ /// #[cfg(feature = "with-builder")]
/// let _ = client.ls_with_options(ipfs_api::request::Ls::builder()
/// .path("/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n")
/// .build()
diff --git a/ipfs-api/src/lib.rs b/ipfs-api/src/lib.rs
index 62a96c8..df5dea2 100644
--- a/ipfs-api/src/lib.rs
+++ b/ipfs-api/src/lib.rs
@@ -21,7 +21,7 @@
//!
//! ```toml
//! [dependencies]
-//! ipfs-api = { version = "0.9.0", features = ["actix"], default-features = false }
+//! ipfs-api = { version = "0.9.0", features = ["with-actix"], default-features = false }
//! ```
//!
//! ## Examples
@@ -140,21 +140,21 @@
//! ```
//!
-#[cfg(feature = "actix")]
+#[cfg(feature = "with-actix")]
extern crate actix_multipart_rfc7578 as actix_multipart;
-#[cfg(feature = "actix")]
+#[cfg(feature = "with-actix")]
#[macro_use]
extern crate derive_more;
-#[cfg(feature = "hyper")]
+#[cfg(feature = "with-hyper")]
extern crate hyper_multipart_rfc7578 as hyper_multipart;
-#[cfg(feature = "hyper")]
+#[cfg(feature = "with-hyper")]
#[macro_use]
extern crate failure;
extern crate serde;
-#[cfg(feature = "builder")]
+#[cfg(feature = "with-builder")]
#[macro_use]
extern crate typed_builder;
@@ -167,33 +167,36 @@ mod read;
pub mod request;
pub mod response;
-#[cfg(feature = "actix")]
+#[cfg(feature = "with-actix")]
use actix_http::{encoding, Payload, PayloadStream};
-#[cfg(feature = "hyper")]
+#[cfg(feature = "with-hyper")]
use hyper::{self, client::HttpConnector};
-#[cfg(all(feature = "hyper-rustls", feature = "hyper-tls"))]
+#[cfg(all(feature = "with-hyper-rustls", feature = "with-hyper-tls"))]
compile_error!("Pick only one of the features: hyper-tls, hyper-rustls");
-#[cfg(all(feature = "hyper-tls", not(feature = "hyper-rustls")))]
+#[cfg(all(feature = "with-hyper-tls", not(feature = "with-hyper-rustls")))]
type HyperConnector = hyper_tls::HttpsConnector<HttpConnector>;
-#[cfg(all(feature = "hyper-rustls", not(feature = "hyper-tls")))]
+#[cfg(all(feature = "with-hyper-rustls", not(feature = "with-hyper-tls")))]
type HyperConnector = hyper_rustls::HttpsConnector<HttpConnector>;
-#[cfg(all(feature = "hyper", any(
- not(any(feature = "hyper-tls", feature = "hyper-rustls")),
- all(feature = "hyper-rustls", feature = "hyper-tls"),
+#[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 = HttpConnector;
-#[cfg(feature = "actix")]
+#[cfg(feature = "with-actix")]
pub(crate) type Request = awc::SendClientRequest;
-#[cfg(feature = "hyper")]
+#[cfg(feature = "with-hyper")]
pub(crate) type Request = http::Request<hyper::Body>;
-#[cfg(feature = "actix")]
+#[cfg(feature = "with-actix")]
pub(crate) type Response = awc::ClientResponse<encoding::Decoder<Payload<PayloadStream>>>;
-#[cfg(feature = "hyper")]
+#[cfg(feature = "with-hyper")]
pub(crate) type Response = http::Response<hyper::Body>;
-#[cfg(feature = "actix")]
+#[cfg(feature = "with-actix")]
pub(crate) type Client = awc::Client;
-#[cfg(feature = "hyper")]
+#[cfg(feature = "with-hyper")]
pub(crate) type Client = hyper::client::Client<HyperConnector, hyper::Body>;
+
+#[cfg(not(any(feature = "with-actix", feature = "with-hyper")))]
+compile_error!("Pick exactly one of these features: with-hyper, with-actix");
diff --git a/ipfs-api/src/request/add.rs b/ipfs-api/src/request/add.rs
index 72001c5..889c617 100644
--- a/ipfs-api/src/request/add.rs
+++ b/ipfs-api/src/request/add.rs
@@ -9,50 +9,50 @@
use crate::request::ApiRequest;
use serde::Serialize;
-#[cfg_attr(feature = "builder", derive(TypedBuilder))]
+#[cfg_attr(feature = "with-builder", derive(TypedBuilder))]
#[derive(Serialize, Default)]
#[serde(rename_all = "kebab-case")]
pub struct Add<'a> {
/// Use trickle-dag format for dag generation.
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub trickle: Option<bool>,
/// Only chunk and hash - do not write to disk.
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub only_hash: Option<bool>,
/// Wrap files with a directory object.
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub wrap_with_directory: Option<bool>,
/// Chunking algorithm, `size-[bytes]`, `rabin-[min]-[avg]-[max]` or `buzhash`.
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub chunker: Option<&'a str>,
/// Pin this object when adding. Defaults to `true`.
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub pin: Option<bool>,
/// Use raw blocks for leaf nodes. (experimental).
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub raw_leaves: Option<bool>,
/// CID version. Defaults to 0 unless an option that depends on CIDv1 is passed.
/// (experimental).
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub cid_version: Option<u32>,
/// Hash function to use. Implies CIDv1 if not sha2-256. (experimental). Default:
/// `sha2-256`.
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub hash: Option<&'a str>,
/// Inline small blocks into CIDs. (experimental).
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub inline: Option<bool>,
/// Maximum block size to inline. (experimental). Default: `32`.
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub inline_limit: Option<u32>,
}
diff --git a/ipfs-api/src/request/files.rs b/ipfs-api/src/request/files.rs
index 498faa9..64cf874 100644
--- a/ipfs-api/src/request/files.rs
+++ b/ipfs-api/src/request/files.rs
@@ -34,17 +34,17 @@ impl<'a> ApiRequest for FilesFlush<'a> {
const PATH: &'static str = "/files/flush";
}
-#[cfg_attr(feature = "builder", derive(TypedBuilder))]
+#[cfg_attr(feature = "with-builder", derive(TypedBuilder))]
#[derive(Serialize, Default)]
pub struct FilesLs<'a> {
#[serde(rename = "arg")]
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub path: Option<&'a str>,
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub long: Option<bool>,
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
#[serde(rename = "U")]
pub unsorted: Option<bool>,
}
@@ -53,23 +53,23 @@ impl<'a> ApiRequest for FilesLs<'a> {
const PATH: &'static str = "/files/ls";
}
-#[cfg_attr(feature = "builder", derive(TypedBuilder))]
+#[cfg_attr(feature = "with-builder", derive(TypedBuilder))]
#[derive(Serialize, Default)]
#[serde(rename_all = "kebab-case")]
pub struct FilesMkdir<'a> {
#[serde(rename = "arg")]
pub path: &'a str,
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub parents: Option<bool>,
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub hash: Option<&'a str>,
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub cid_version: Option<i32>,
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub flush: Option<bool>,
}
@@ -92,16 +92,16 @@ impl<'a> ApiRequest for FilesMv<'a> {
const PATH: &'static str = "/files/mv";
}
-#[cfg_attr(feature = "builder", derive(TypedBuilder))]
+#[cfg_attr(feature = "with-builder", derive(TypedBuilder