summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerris Tseng <ferristseng@fastmail.fm>2021-01-18 21:10:03 -0500
committerGitHub <noreply@github.com>2021-01-18 21:10:03 -0500
commitf8826be86fed99e01d7d27e8625a954fba74befe (patch)
treec1a094f6fb6a0204ab22b286087832d4ffabada6
parent57f27461943670f3d024e0e4ece9fb2a15035344 (diff)
parentd53e6d335c3cfde51f6ceebd2da5306f5ed86ce8 (diff)
Merge pull request #64 from jcaesar/optional-tls
allow hyper-rustls or no tls as alternatives for hyper-tls
-rw-r--r--Cargo.lock199
-rw-r--r--README.md2
-rw-r--r--ipfs-api/Cargo.toml13
-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.rs71
-rw-r--r--ipfs-api/src/lib.rs46
-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
25 files changed, 381 insertions, 170 deletions
diff --git a/Cargo.lock b/Cargo.lock
index b5f2d59..d17fb59 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -481,6 +481,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb"
[[package]]
+name = "bumpalo"
+version = "3.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
+
+[[package]]
name = "byteorder"
version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -503,9 +509,9 @@ dependencies = [
[[package]]
name = "cc"
-version = "1.0.61"
+version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed67cbde08356238e75fc4656be4749481eeffb09e19f320a25237d5221c985d"
+checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48"
[[package]]
name = "cfg-if"
@@ -618,6 +624,15 @@ dependencies = [
]
[[package]]
+name = "ct-logs"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4d3686f5fa27dbc1d76c751300376e167c5a43387f44bb451fd1c24776e49113"
+dependencies = [
+ "sct",
+]
+
+[[package]]
name = "data-encoding"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1042,6 +1057,24 @@ dependencies = [
]
[[package]]
+name = "hyper-rustls"
+version = "0.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac965ea399ec3a25ac7d13b8affd4b8f39325cca00858ddf5eb29b79e6b14b08"
+dependencies = [
+ "bytes",
+ "ct-logs",
+ "futures-util",
+ "hyper",
+ "log",
+ "rustls",
+ "rustls-native-certs",
+ "tokio",
+ "tokio-rustls",
+ "webpki",
+]
+
+[[package]]
name = "hyper-tls"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1121,6 +1154,7 @@ dependencies = [
"http",
"hyper",
"hyper-multipart-rfc7578",
+ "hyper-rustls",
"hyper-tls",
"parity-multiaddr",
"serde",
@@ -1140,6 +1174,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
[[package]]
+name = "js-sys"
+version = "0.3.46"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175"
+dependencies = [
+ "wasm-bindgen",
+]
+
+[[package]]
name = "keccak"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1363,9 +1406,9 @@ checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397"
[[package]]
name = "once_cell"
-version = "1.4.1"
+version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad"
+checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0"
[[package]]
name = "opaque-debug"
@@ -1680,6 +1723,21 @@ dependencies = [
]
[[package]]
+name = "ring"
+version = "0.16.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "024a1e66fea74c66c66624ee5622a7ff0e4b73a13b4f5c326ddb50c708944226"
+dependencies = [
+ "cc",
+ "libc",
+ "once_cell",
+ "spin",
+ "untrusted",
+ "web-sys",
+ "winapi 0.3.9",
+]
+
+[[package]]
name = "rust-argon2"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1698,6 +1756,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232"
[[package]]
+name = "rustls"
+version = "0.17.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1"
+dependencies = [
+ "base64 0.11.0",
+ "log",
+ "ring",
+ "sct",
+ "webpki",
+]
+
+[[package]]
+name = "rustls-native-certs"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75ffeb84a6bd9d014713119542ce415db3a3e4748f0bfce1e1416cd224a23a5"
+dependencies = [
+ "openssl-probe",
+ "rustls",
+ "schannel",
+ "security-framework",
+]
+
+[[package]]
name = "ryu"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1729,6 +1812,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
+name = "sct"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c"
+dependencies = [
+ "ring",
+ "untrusted",
+]
+
+[[package]]
name = "security-framework"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1872,6 +1965,12 @@ dependencies = [
]
[[package]]
+name = "spin"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
+
+[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1996,6 +2095,18 @@ dependencies = [
]
[[package]]
+name = "tokio-rustls"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "15cb62a0d2770787abc96e99c1cd98fcf17f94959f3af63ca85bdfb203f051b4"
+dependencies = [
+ "futures-core",
+ "rustls",
+ "tokio",
+ "webpki",
+]
+
+[[package]]
name = "tokio-tls"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2169,6 +2280,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fdeedbf205afadfe39ae559b75c3240f24e257d0ca27e85f85cb82aa19ac35"
[[package]]
+name = "untrusted"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
+
+[[package]]
name = "url"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2225,6 +2342,80 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]]
+name = "wasm-bindgen"
+version = "0.2.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e"
+dependencies = [
+ "cfg-if 1.0.0",
+ "wasm-bindgen-macro",
+]
+
+[[package]]
+name = "wasm-bindgen-backend"
+version = "0.2.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62"
+dependencies = [
+ "bumpalo",
+ "lazy_static",
+ "log",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-backend",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158"
+
+[[package]]
+name = "web-sys"
+version = "0.3.46"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3"
+dependencies = [
+ "js-sys",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "webpki"
+version = "0.21.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea"
+dependencies = [
+ "ring",
+ "untrusted",
+]
+
+[[package]]
name = "widestring"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
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 88ed983..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 }
@@ -30,6 +36,7 @@ futures = "0.3"
http = "0.2"
hyper = { version = "0.13", optional = true }
hyper-tls = { version = "0.4", optional = true }
+hyper-rustls = { version = "0.20", optional = true }
hyper-multipart-rfc7578 = { version = "0.4.0-rc", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
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 2b1f62f..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,15 +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")]
-use hyper_tls::HttpsConnector;
+#[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,
@@ -44,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.
@@ -60,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(HttpsConnector::new())
+ .build(HyperConnector::new())
}
- #[cfg(feature = "actix")]
+ #[cfg(feature = "with-actix")]
{
Client::default()
}
@@ -104,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);
@@ -118,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
@@ -170,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)
}
@@ -192,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();
@@ -200,7 +201,7 @@ impl IpfsClient {
Ok((status, body))
}
- #[cfg(feature = "actix")]
+ #[cfg(feature = "with-actix")]
{
let mut res = req.await?;
let status = res.status();
@@ -279,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)
@@ -303,7 +304,7 @@ impl IpfsClient {
})
.try_flatten_stream()
}
- #[cfg(feature = "actix")]
+ #[cfg(feature = "with-actix")]
{
req.err_into()
.map_ok(move |mut res| {
@@ -331,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())
}
@@ -432,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()
@@ -1323,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),
@@ -1378,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),
@@ -1471,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),
@@ -1524,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),
@@ -1620,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")]
+ /