summaryrefslogtreecommitdiffstats
path: root/ipfs-api/src
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 /ipfs-api/src
parentc465720a494312aea93aa87e16ff6baf25ef2e11 (diff)
Reorganize features
Diffstat (limited to 'ipfs-api/src')
-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
6 files changed, 134 insertions, 131 deletions
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))]
#[derive(Serialize, Default)]
pub struct FilesRead<'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 offset: Option<i64>,
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub count: Option<i64>,
}
@@ -109,16 +109,16 @@ impl<'a> ApiRequest for FilesRead<'a> {
const PATH: &'static str = "/files/read";
}
-#[cfg_attr(feature = "builder", derive(TypedBuilder))]
+#[cfg_attr(feature = "with-builder", derive(TypedBuilder))]
#[derive(Serialize, Default)]
pub struct FilesRm<'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 recursive: Option<bool>,
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub flush: Option<bool>,
}
@@ -139,38 +139,38 @@ impl<'a> ApiRequest for FilesStat<'a> {
const PATH: &'static str = "/files/stat";
}
-#[cfg_attr(feature = "builder", derive(TypedBuilder))]
+#[cfg_attr(feature = "with-builder", derive(TypedBuilder))]
#[derive(Serialize, Default)]
#[serde(rename_all = "kebab-case")]
pub struct FilesWrite<'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 create: Option<bool>,
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub truncate: Option<bool>,
- #[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 offset: Option<i64>,
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub count: Option<i64>,
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub raw_leaves: 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>,
}
@@ -178,21 +178,21 @@ impl<'a> ApiRequest for FilesWrite<'a> {
const PATH: &'static str = "/files/write";
}
-#[cfg_attr(feature = "builder", derive(TypedBuilder))]
+#[cfg_attr(feature = "with-builder", derive(TypedBuilder))]
#[derive(Serialize, Default)]
#[serde(rename_all = "kebab-case")]
pub struct FilesChcid<'a> {
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
#[serde(rename = "arg")]
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 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>,
}
diff --git a/ipfs-api/src/request/ls.rs b/ipfs-api/src/request/ls.rs
index d3c932c..204d067 100644
--- a/ipfs-api/src/request/ls.rs
+++ b/ipfs-api/src/request/ls.rs
@@ -9,20 +9,20 @@
use crate::request::ApiRequest;
use crate::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 Ls<'a> {
#[serde(rename = "arg")]
pub path: &'a str,
/// Resolve linked objects to find out their types. Default: `true`
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub resolve_type: Option<bool>,
/// Resolve linked objects to find out their file size. Default: `true`
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub size: Option<bool>,
/// Enable experimental streaming of directory entries as they are traversed.
- #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
+ #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
pub stream: Option<bool>,
}
diff --git a/ipfs-api/src/response/error.rs b/ipfs-api/src/response/error.rs
index c98d183..996a313 100644
--- a/ipfs-api/src/response/error.rs
+++ b/ipfs-api/src/response/error.rs
@@ -9,8 +9,8 @@
use crate::serde::Deserialize;
use std::string::FromUtf8Error;
-#[cfg_attr(feature = "actix", derive(Display), display(fmt = "{}", message))]
-#[cfg_attr(feature = "hyper", derive(Fail), fail(display = "{}", message))]
+#[cfg_attr(feature = "with-actix", derive(Display), display(fmt = "{}", message))]
+#[cfg_attr(feature = "with-hyper", derive(Fail), fail(display = "{}", message))]
#[derive(Debug, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct ApiError {
@@ -18,106 +18,106 @@ pub struct ApiError {
pub code: u8,
}
-#[cfg_attr(feature = "actix", derive(Display))]
-#[cfg_attr(feature = "hyper", derive(Fail))]
+#[cfg_attr(feature = "with-actix", derive(Display))]
+#[cfg_attr(feature = "with-hyper", derive(Fail))]
#[derive(Debug)]
pub enum Error {
/// Foreign errors.
- #[cfg(feature = "hyper")]
- #[cfg_attr(feature = "hyper", fail(display = "hyper client error '{}'", _0))]
+ #[cfg(feature = "with-hyper")]
+ #[cfg_attr(feature = "with-hyper", fail(display = "hyper client error '{}'", _0))]
Client(hyper::Error),
- #[cfg(feature = "actix")]
+ #[cfg(feature = "with-actix")]
#[cfg_attr(
- feature = "actix",
+ feature = "with-actix",
display(fmt = "actix client payload error '{}'", _0)
)]
ClientPayload(awc::error::PayloadError),
- #[cfg(feature = "actix")]
+ #[cfg(feature = "with-actix")]
#[cfg_attr(
- feature = "actix",
+ feature = "with-actix",
display(fmt = "actix client send request error '{}'", _0)
)]
ClientSend(awc::error::SendRequestError),
- #[cfg_attr(feature = "actix", display(fmt = "http error '{}'", _0))]
- #[cfg_attr(feature = "hyper", fail(display = "http error '{}'", _0))]
+ #[cfg_attr(feature = "with-actix", display(fmt = "http error '{}'", _0))]
+ #[cfg_attr(feature = "with-hyper", fail(display = "http error '{}'", _0))]
Http(http::Error),
- #[cfg_attr(feature = "actix", display(fmt = "json parse error '{}'", _0))]
- #[cfg_attr(feature = "hyper", fail(display = "json parse error '{}'", _0))]
+ #[cfg_attr(feature = "with-actix", display(fmt = "json parse error '{}'", _0))]
+ #[cfg_attr(feature = "with-hyper", fail(display = "json parse error '{}'", _0))]
Parse(serde_json::Error),
- #[cfg_attr(feature = "actix", display(fmt = "utf8 decoding error '{}'", _0))]
- #[cfg_attr(feature = "hyper", fail(display = "utf8 decoding error '{}'", _0))]
+ #[cfg_attr(feature = "with-actix", display(fmt = "utf8 decoding error '{}'", _0))]
+ #[cfg_attr(feature = "with-hyper", fail(display = "utf8 decoding error '{}'", _0))]
ParseUtf8(FromUtf8Error),
- #[cfg_attr(feature = "actix", display(fmt = "uri error '{}'", _0))]
- #[cfg_attr(feature = "hyper", fail(display = "uri error '{}'", _0))]
+ #[cfg_attr(feature = "with-actix", display(fmt = "uri error '{}'", _0))]
+ #[cfg_attr(feature = "with-hyper", fail(display = "uri error '{}'", _0))]
Url(http::uri::InvalidUri),
- #[cfg_attr(feature = "actix", display(fmt = "io error '{}'", _0))]
- #[cfg_attr(feature = "hyper", fail(display = "io error '{}'", _0))]
+ #[cfg_attr(feature = "with-actix", display(fmt = "io error '{}'", _0))]
+ #[cfg_attr(feature = "with-hyper", fail(display = "io error '{}'", _0))]
Io(std::io::Error),
- #[cfg_attr(feature = "actix", display(fmt = "url encoding error '{}'", _0))]
- #[cfg_attr(feature = "hyper", fail(display = "url encoding error '{}'", _0))]
+ #[cfg_attr(feature = "with-actix", display(fmt = "url encoding error '{}'", _0))]
+ #[cfg_attr(feature = "with-hyper", fail(display = "url encoding error '{}'", _0))]
EncodeUrl(serde_urlencoded::ser::Error),
/// An error returned by the Ipfs api.
- #[cfg_attr(feature = "actix", display(fmt = "api returned error '{}'", _0))]
- #[cfg_attr(feature = "hyper", fail(display = "api returned error '{}'", _0))]
+ #[cfg_attr(feature = "with-actix", display(fmt = "api returned error '{}'", _0))]
+ #[cfg_attr(feature = "with-hyper", fail(display = "api returned error '{}'", _0))]
Api(ApiError),
/// A stream error indicated in the Trailer header.
#[cfg_attr(
- feature = "actix",
+ feature = "with-actix",
display(fmt = "api returned an error while streaming: '{}'", _0)
)]
#[cfg_attr(
- feature = "hyper",
+ feature = "with-hyper",
fail(display = "api returned an error while streaming: '{}'", _0)
)]
StreamError(String),
/// API returned a trailer header with unrecognized value.
#[cfg_attr(
- feature = "actix",
+ feature = "with-actix",
display(fmt = "api returned a trailer header with unknown value: '{}'", _0)
)]
#[cfg_attr(
- feature = "hyper",
+ feature = "with-hyper",
fail(display = "api returned a trailer header with unknown value: '{}'", _0)
)]
UnrecognizedTrailerHeader(String),
#[cfg_attr(
- feature = "actix",
+ feature = "with-actix",
display(fmt = "api returned unknwon error '{}'", _0)
)]
#[cfg_attr(
- feature = "hyper",
+ feature = "with-hyper",
fail(display = "api returned unknwon error '{}'", _0)
)]
Uncategorized(String),
}
-#[cfg(feature = "hyper")]
+#[cfg(feature = "with-hyper")]
impl From<hyper::Error> for Error {
fn from(err: hyper::Error) -> Error {
Error::Client(err)
}
}
-#[cfg(feature = "actix")]
+#[cfg(feature = "with-actix")]
impl From<awc::error::SendRequestError> for Error {
fn from(err: awc::error::SendRequestError) -> Error {
Error::ClientSend(err)
}
}
-#[cfg(feature = "actix")]
+#[cfg(feature = "with-actix")]
impl From<awc::error::PayloadError> for Error {
fn from(err: awc::error::PayloadError) -> Error {
Error::ClientPayload(err)