From cef3df9cd1958315dcc5cc4264a82e2574310330 Mon Sep 17 00:00:00 2001 From: Ferris Tseng Date: Tue, 24 Dec 2019 12:59:51 -0500 Subject: cleaning up doc tests --- Cargo.lock | 71 ------- ipfs-api/src/client.rs | 553 +++++++++++-------------------------------------- ipfs-api/src/lib.rs | 137 ++++++------ 3 files changed, 183 insertions(+), 578 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c98dc49..0681c16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -266,14 +266,6 @@ dependencies = [ "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "arc-swap" version = "0.4.4" @@ -299,15 +291,6 @@ dependencies = [ "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "atty" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "autocfg" version = "0.1.7" @@ -476,20 +459,6 @@ dependencies = [ "multihash 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "clap" -version = "2.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "cloudabi" version = "0.0.3" @@ -997,16 +966,6 @@ dependencies = [ "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ipfs-cli" -version = "0.4.1" -dependencies = [ - "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ipfs-api 0.5.2", -] - [[package]] name = "itoa" version = "0.4.4" @@ -1622,11 +1581,6 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "syn" version = "1.0.11" @@ -1672,14 +1626,6 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "thread_local" version = "0.3.6" @@ -1840,11 +1786,6 @@ name = "unicode-segmentation" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "unicode-width" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "unicode-xid" version = "0.2.0" @@ -1865,11 +1806,6 @@ name = "vcpkg" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "vec_map" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "walkdir" version = "2.2.9" @@ -1987,12 +1923,10 @@ dependencies = [ "checksum actix-web-codegen 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de0878b30e62623770a4713a6338329fd0119703bafc211d3e4144f4d4a7bdd5" "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" -"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" "checksum async-trait 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "8b6dd385bb33043b833ba049048d57bdbb4d654a121ed68c71871ca51ff67070" -"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum awc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d7601d4d1d7ef2335d6597a41b5fe069f6ab799b85f53565ab390e7b7065aac5" "checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" @@ -2014,7 +1948,6 @@ dependencies = [ "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01" "checksum cid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6908948032561f2550467a477f659cdc358320a805237b9b5035c0350c441def" -"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum common-multipart-rfc7578 0.2.0-rc (registry+https://github.com/rust-lang/crates.io-index)" = "7471b7b1588b2cda44e0cdf3fd3da5706c1b46224dbf486c3daceb6655ec191c" "checksum constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120" @@ -2145,12 +2078,10 @@ dependencies = [ "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" "checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" -"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" "checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" "checksum tar 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "b3196bfbffbba3e57481b6ea32249fbaf590396a52505a2615adbb79d9d826d3" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" -"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" @@ -2167,11 +2098,9 @@ dependencies = [ "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b561e267b2326bb4cebfc0ef9e68355c7abe6c6f522aeac2f5bf95d56c59bdcf" "checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" -"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61" "checksum vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" -"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9658c94fa8b940eab2250bd5a457f9c48b748420d71293b165c8cdbe2f55f71e" "checksum want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" "checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" diff --git a/ipfs-api/src/client.rs b/ipfs-api/src/client.rs index 8465e07..880af32 100644 --- a/ipfs-api/src/client.rs +++ b/ipfs-api/src/client.rs @@ -472,16 +472,12 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// use std::io::Cursor; /// - /// # fn main() { /// let client = IpfsClient::default(); /// let data = Cursor::new("Hello World!"); - /// let req = client.add(data); - /// # } + /// let res = client.add(data); /// ``` /// #[inline] @@ -504,15 +500,11 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); /// let path = "./src"; - /// let req = client.add_path(path); - /// # } + /// let res = client.add_path(path); /// ``` /// #[inline] @@ -582,14 +574,10 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.bitswap_ledger("QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"); - /// # } + /// let res = client.bitswap_ledger("QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"); /// ``` /// #[inline] @@ -605,14 +593,10 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.bitswap_reprovide(); - /// # } + /// let res = client.bitswap_reprovide(); /// ``` /// #[inline] @@ -625,14 +609,10 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.bitswap_stat(); - /// # } + /// let res = client.bitswap_stat(); /// ``` /// #[inline] @@ -645,14 +625,10 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.bitswap_unwant("QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA"); - /// # } + /// let res = client.bitswap_unwant("QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA"); /// ``` /// #[inline] @@ -669,14 +645,12 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.bitswap_wantlist(Some("QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ")); - /// # } + /// let res = client.bitswap_wantlist( + /// Some("QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ") + /// ); /// ``` /// #[inline] @@ -692,17 +666,15 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate futures; - /// # extern crate ipfs_api; - /// # - /// use futures::Stream; + /// use futures::TryStreamExt; /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); /// let hash = "QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA"; - /// let req = client.block_get(hash).concat2(); - /// # } + /// let res = client + /// .block_get(hash) + /// .map_ok(|chunk| chunk.to_vec()) + /// .try_concat(); /// ``` /// #[inline] @@ -715,16 +687,12 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// use std::io::Cursor; /// - /// # fn main() { /// let client = IpfsClient::default(); /// let data = Cursor::new("Hello World!"); - /// let req = client.block_put(data); - /// # } + /// let res = client.block_put(data); /// ``` /// #[inline] @@ -744,14 +712,10 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.block_rm("QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA"); - /// # } + /// let res = client.block_rm("QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA"); /// ``` /// #[inline] @@ -764,14 +728,10 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.block_stat("QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA"); - /// # } + /// let res = client.block_stat("QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA"); /// ``` /// #[inline] @@ -784,14 +744,10 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.bootstrap_add_default(); - /// # } + /// let res = client.bootstrap_add_default(); /// ``` /// #[inline] @@ -806,14 +762,10 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.bootstrap_list(); - /// # } + /// let res = client.bootstrap_list(); /// ``` /// #[inline] @@ -826,14 +778,10 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.bootstrap_rm_all(); - /// # } + /// let res = client.bootstrap_rm_all(); /// ``` /// #[inline] @@ -846,17 +794,15 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate futures; - /// # extern crate ipfs_api; - /// # - /// use futures::Stream; + /// use futures::TryStreamExt; /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); /// let hash = "QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA"; - /// let req = client.cat(hash).concat2(); - /// # } + /// let res = client + /// .cat(hash) + /// .map_ok(|chunk| chunk.to_vec()) + /// .try_concat(); /// ``` /// #[inline] @@ -867,14 +813,10 @@ impl IpfsClient { /// List available commands that the server accepts. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.commands(); - /// # } + /// let res = client.commands(); /// ``` /// #[inline] @@ -885,14 +827,10 @@ impl IpfsClient { /// Opens the config file for editing (on the server). /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.config_edit(); - /// # } + /// let res = client.config_edit(); /// ``` /// #[inline] @@ -903,16 +841,12 @@ impl IpfsClient { /// Replace the config file. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// use std::io::Cursor; /// - /// # fn main() { /// let client = IpfsClient::default(); /// let config = Cursor::new("{..json..}"); - /// let req = client.config_replace(config); - /// # } + /// let res = client.config_replace(config); /// ``` /// #[inline] @@ -932,14 +866,10 @@ impl IpfsClient { /// Returns an unparsed json string, due to an unclear spec. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.config_show(); - /// # } + /// let res = client.config_show(); /// ``` /// #[inline] @@ -950,14 +880,10 @@ impl IpfsClient { /// Returns information about a dag node in Ipfs. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.dag_get("QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA"); - /// # } + /// let res = client.dag_get("QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA"); /// ``` /// #[inline] @@ -987,17 +913,12 @@ impl IpfsClient { /// Query the DHT for all of the multiaddresses associated with a Peer ID. /// /// ```no_run - /// # extern crate futures; - /// # extern crate ipfs_api; - /// # - /// use futures::Stream; + /// use futures::TryStreamExt; /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); /// let peer = "QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM"; - /// let req = client.dht_findpeer(peer).collect(); - /// # } + /// let res = client.dht_findpeer(peer).try_collect::>(); /// ``` /// #[inline] @@ -1008,17 +929,12 @@ impl IpfsClient { /// Find peers in the DHT that can provide a specific value given a key. /// /// ```no_run - /// # extern crate futures; - /// # extern crate ipfs_api; - /// # - /// use futures::Stream; + /// use futures::TryStreamExt; /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); /// let key = "QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA"; - /// let req = client.dht_findprovs(key).collect(); - /// # } + /// let res = client.dht_findprovs(key).try_collect::>(); /// ``` /// #[inline] @@ -1029,17 +945,12 @@ impl IpfsClient { /// Query the DHT for a given key. /// /// ```no_run - /// # extern crate futures; - /// # extern crate ipfs_api; - /// # - /// use futures::Stream; + /// use futures::TryStreamExt; /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); /// let key = "QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA"; - /// let req = client.dht_get(key).collect(); - /// # } + /// let res = client.dht_get(key).try_collect::>(); /// ``` /// #[inline] @@ -1050,17 +961,12 @@ impl IpfsClient { /// Announce to the network that you are providing a given value. /// /// ```no_run - /// # extern crate futures; - /// # extern crate ipfs_api; - /// # - /// use futures::Stream; + /// use futures::TryStreamExt; /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); /// let key = "QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA"; - /// let req = client.dht_provide(key).collect(); - /// # } + /// let res = client.dht_provide(key).try_collect::>(); /// ``` /// #[inline] @@ -1071,16 +977,11 @@ impl IpfsClient { /// Write a key/value pair to the DHT. /// /// ```no_run - /// # extern crate futures; - /// # extern crate ipfs_api; - /// # - /// use futures::Stream; + /// use futures::TryStreamExt; /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.dht_put("test", "Hello World!").collect(); - /// # } + /// let res = client.dht_put("test", "Hello World!").try_collect::>(); /// ``` /// #[inline] @@ -1091,17 +992,12 @@ impl IpfsClient { /// Find the closest peer given the peer ID by querying the DHT. /// /// ```no_run - /// # extern crate futures; - /// # extern crate ipfs_api; - /// # - /// use futures::Stream; + /// use futures::TryStreamExt; /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); /// let peer = "QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM"; - /// let req = client.dht_query(peer).collect(); - /// # } + /// let res = client.dht_query(peer).try_collect::>(); /// ``` /// #[inline] @@ -1112,14 +1008,10 @@ impl IpfsClient { /// Clear inactive requests from the log. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.diag_cmds_clear(); - /// # } + /// let res = client.diag_cmds_clear(); /// ``` /// #[inline] @@ -1130,14 +1022,10 @@ impl IpfsClient { /// Set how long to keep inactive requests in the log. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.diag_cmds_set_time("1m"); - /// # } + /// let res = client.diag_cmds_set_time("1m"); /// ``` /// #[inline] @@ -1156,14 +1044,10 @@ impl IpfsClient { /// an actual object. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.diag_sys(); - /// # } + /// let res = client.diag_sys(); /// ``` /// #[inline] @@ -1174,14 +1058,10 @@ impl IpfsClient { /// Resolve DNS link. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.dns("ipfs.io", true); - /// # } + /// let res = client.dns("ipfs.io", true); /// ``` /// #[inline] @@ -1192,14 +1072,10 @@ impl IpfsClient { /// List directory for Unix filesystem objects. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.file_ls("/ipns/ipfs.io"); - /// # } + /// let res = client.file_ls("/ipns/ipfs.io"); /// ``` /// #[inline] @@ -1210,14 +1086,10 @@ impl IpfsClient { /// Copy files into MFS. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.files_cp("/path/to/file", "/dest"); - /// # } + /// let res = client.files_cp("/path/to/file", "/dest"); /// ``` /// #[inline] @@ -1233,15 +1105,11 @@ impl IpfsClient { /// Flush a path's data to disk. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.files_flush(None); - /// let req = client.files_flush(Some("/tmp")); - /// # } + /// let res = client.files_flush(None); + /// let res = client.files_flush(Some("/tmp")); /// ``` /// #[inline] @@ -1255,15 +1123,11 @@ impl IpfsClient { /// List directories in MFS. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.files_ls(None); - /// let req = client.files_ls(Some("/tmp")); - /// # } + /// let res = client.files_ls(None); + /// let res = client.files_ls(Some("/tmp")); /// ``` /// #[inline] @@ -1274,15 +1138,11 @@ impl IpfsClient { /// Make directories in MFS. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.files_mkdir("/test", false); - /// let req = client.files_mkdir("/test/nested/dir", true); - /// # } + /// let res = client.files_mkdir("/test", false); + /// let res = client.files_mkdir("/test/nested/dir", true); /// ``` /// #[inline] @@ -1298,14 +1158,10 @@ impl IpfsClient { /// Copy files into MFS. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.files_mv("/test/tmp.json", "/test/file.json"); - /// # } + /// let res = client.files_mv("/test/tmp.json", "/test/file.json"); /// ``` /// #[inline] @@ -1321,14 +1177,10 @@ impl IpfsClient { /// Read a file in MFS. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.files_read("/test/file.json"); - /// # } + /// let res = client.files_read("/test/file.json"); /// ``` /// #[inline] @@ -1339,15 +1191,11 @@ impl IpfsClient { /// Remove a file in MFS. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.files_rm("/test/dir", true); - /// let req = client.files_rm("/test/file.json", false); - /// # } + /// let res = client.files_rm("/test/dir", true); + /// let res = client.files_rm("/test/file.json", false); /// ``` /// #[inline] @@ -1363,14 +1211,10 @@ impl IpfsClient { /// Display a file's status in MDFS. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.files_stat("/test/file.json"); - /// # } + /// let res = client.files_stat("/test/file.json"); /// ``` /// #[inline] @@ -1381,16 +1225,12 @@ impl IpfsClient { /// Write to a mutable file in the filesystem. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// use std::fs::File; /// - /// # fn main() { /// let client = IpfsClient::default(); /// let file = File::open("test.json").unwrap(); - /// let req = client.files_write("/test/file.json", true, true, file); - /// # } + /// let res = client.files_write("/test/file.json", true, true, file); /// ``` /// #[inline] @@ -1422,14 +1262,10 @@ impl IpfsClient { /// List blocks that are both in the filestore and standard block storage. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.filestore_dups(); - /// # } + /// let res = client.filestore_dups(); /// ``` /// #[inline] @@ -1440,14 +1276,12 @@ impl IpfsClient { /// List objects in filestore. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.filestore_ls(Some("QmYPP3BovR2m8UqCZxFbdXSit6SKgExxDkFAPLqiGsap4X")); - /// # } + /// let res = client.filestore_ls( + /// Some("QmYPP3BovR2m8UqCZxFbdXSit6SKgExxDkFAPLqiGsap4X") + /// ); /// ``` /// #[inline] @@ -1461,14 +1295,10 @@ impl IpfsClient { /// Verify objects in filestore. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.filestore_verify(None); - /// # } + /// let res = client.filestore_verify(None); /// ``` /// #[inline] @@ -1482,14 +1312,10 @@ impl IpfsClient { /// Download Ipfs object. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.get("/test/file.json"); - /// # } + /// let res = client.get("/test/file.json"); /// ``` /// #[inline] @@ -1502,15 +1328,11 @@ impl IpfsClient { /// If `peer` is `None`, returns information about you. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.id(None); - /// let req = client.id(Some("QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM")); - /// # } + /// let res = client.id(None); + /// let res = client.id(Some("QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM")); /// ``` /// #[inline] @@ -1521,14 +1343,10 @@ impl IpfsClient { /// Create a new keypair. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::{IpfsClient, KeyType}; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.key_gen("test", KeyType::Rsa, 64); - /// # } + /// let res = client.key_gen("test", KeyType::Rsa, 64); /// ``` /// #[inline] @@ -1545,14 +1363,10 @@ impl IpfsClient { /// List all local keypairs. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.key_list(); - /// # } + /// let res = client.key_list(); /// ``` /// #[inline] @@ -1563,14 +1377,10 @@ impl IpfsClient { /// Rename a keypair. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.key_rename("key_0", "new_name", false); - /// # } + /// let res = client.key_rename("key_0", "new_name", false); /// ``` /// #[inline] @@ -1587,14 +1397,10 @@ impl IpfsClient { /// Remove a keypair. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.key_rm("key_0"); - /// # } + /// let res = client.key_rm("key_0"); /// ``` /// #[inline] @@ -1605,18 +1411,15 @@ impl IpfsClient { /// Change the logging level for a logger. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::{IpfsClient, Logger, LoggingLevel}; /// use std::borrow::Cow; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.log_level(Logger::All, LoggingLevel::Debug); - /// let req = client.log_level( + /// let res = client.log_level(Logger::All, LoggingLevel::Debug); + /// let res = client.log_level( /// Logger::Specific(Cow::Borrowed("web")), - /// LoggingLevel::Warning); - /// # } + /// LoggingLevel::Warning + /// ); /// ``` /// #[inline] @@ -1632,14 +1435,10 @@ impl IpfsClient { /// List all logging subsystems. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.log_ls(); - /// # } + /// let res = client.log_ls(); /// ``` /// #[inline] @@ -1657,7 +1456,7 @@ impl IpfsClient { /// /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.log_tail(); + /// let res = client.log_tail(); /// # } /// ``` /// @@ -1688,15 +1487,11 @@ impl IpfsClient { /// List the contents of an Ipfs multihash. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.ls(None); - /// let req = client.ls(Some("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY")); - /// # } + /// let res = client.ls(None); + /// let res = client.ls(Some("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY")); /// ``` /// #[inline] @@ -1709,19 +1504,16 @@ impl IpfsClient { /// Publish an IPFS path to IPNS. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.name_publish( + /// let res = client.name_publish( /// "/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY", /// false, /// Some("12h"), /// None, - /// None); - /// # } + /// None + /// ); /// ``` /// pub async fn name_publish( @@ -1748,17 +1540,14 @@ impl IpfsClient { /// Resolve an IPNS name. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.name_resolve( + /// let res = client.name_resolve( /// Some("/ipns/ipfs.io"), /// true, - /// false); - /// # } + /// false + /// ); /// ``` /// pub async fn name_resolve( @@ -1781,14 +1570,10 @@ impl IpfsClient { /// Output the raw bytes of an Ipfs object. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.object_data("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY"); - /// # } + /// let res = client.object_data("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY"); /// ``` /// #[inline] @@ -1799,16 +1584,13 @@ impl IpfsClient { /// Returns the diff of two Ipfs objects. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.object_diff( + /// let res = client.object_diff( /// "/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY", - /// "/ipfs/QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA"); - /// # } + /// "/ipfs/QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA" + /// ); /// ``` /// #[inline] @@ -1823,14 +1605,10 @@ impl IpfsClient { /// Returns the data in an object. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.object_get("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY"); - /// # } + /// let res = client.object_get("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY"); /// ``` /// #[inline] @@ -1841,14 +1619,10 @@ impl IpfsClient { /// Returns the links that an object points to. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.object_links("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY"); - /// # } + /// let res = client.object_links("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY"); /// ``` /// #[inline] @@ -1859,15 +1633,11 @@ impl IpfsClient { /// Create a new object. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::{IpfsClient, ObjectTemplate}; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.object_new(None); - /// let req = client.object_new(Some(ObjectTemplate::UnixFsDir)); - /// # } + /// let res = client.object_new(None); + /// let res = client.object_new(Some(ObjectTemplate::UnixFsDir)); /// ``` /// #[inline] @@ -1891,14 +1661,10 @@ impl IpfsClient { /// Returns the stats for an object. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.object_stat("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY"); - /// # } + /// let res = client.object_stat("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY"); /// ``` /// #[inline] @@ -1930,14 +1696,10 @@ impl IpfsClient { /// # Examples /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.pin_add("QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", true); - /// # } + /// let res = client.pin_add("QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", true); /// ``` #[inline] pub async fn pin_add( @@ -1959,18 +1721,15 @@ impl IpfsClient { /// Returns a list of pinned objects in local storage. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.pin_ls(None, None); - /// let req = client.pin_ls( + /// let res = client.pin_ls(None, None); + /// let res = client.pin_ls( /// Some("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY"), - /// None); - /// let req = client.pin_ls(None, Some("direct")); - /// # } + /// None + /// ); + /// let res = client.pin_ls(None, Some("direct")); /// ``` /// #[inline] @@ -1985,19 +1744,17 @@ impl IpfsClient { /// Removes a pinned object from local storage. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.pin_rm( + /// let res = client.pin_rm( /// "/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY", - /// false); - /// let req = client.pin_rm( + /// false + /// ); + /// let res = client.pin_rm( /// "/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY", - /// true); - /// # } + /// true + /// ); /// ``` /// #[inline] @@ -2016,15 +1773,11 @@ impl IpfsClient { /// Pings a peer. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.ping("QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", None); - /// let req = client.ping("QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", Some(15)); - /// # } + /// let res = client.ping("QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", None); + /// let res = client.ping("QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", Some(15)); /// ``` /// #[inline] @@ -2039,14 +1792,10 @@ impl IpfsClient { /// List subscribed pubsub topics. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.pubsub_ls(); - /// # } + /// let res = client.pubsub_ls(); /// ``` /// #[inline] @@ -2057,15 +1806,11 @@ impl IpfsClient { /// List peers that are being published to. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.pubsub_peers(None); - /// let req = client.pubsub_peers(Some("feed")); - /// # } + /// let res = client.pubsub_peers(None); + /// let res = client.pubsub_peers(Some("feed")); /// ``` /// #[inline] @@ -2079,14 +1824,10 @@ impl IpfsClient { /// Publish a message to a topic. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.pubsub_pub("feed", "Hello World!"); - /// # } + /// let res = client.pubsub_pub("feed", "Hello World!"); /// ``` /// #[inline] @@ -2102,15 +1843,11 @@ impl IpfsClient { /// Subscribes to a pubsub topic. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.pubsub_sub("feed", false); - /// let req = client.pubsub_sub("feed", true); - /// # } + /// let res = client.pubsub_sub("feed", false); + /// let res = client.pubsub_sub("feed", true); /// ``` /// #[inline] @@ -2125,14 +1862,10 @@ impl IpfsClient { /// Gets a list of local references. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.refs_local(); - /// # } + /// let res = client.refs_local(); /// ``` /// #[inline] @@ -2155,14 +1888,10 @@ impl IpfsClient { /// Shutdown the Ipfs daemon. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.shutdown(); - /// # } + /// let res = client.shutdown(); /// ``` /// pub async fn shutdown(&self) -> Result { @@ -2172,14 +1901,10 @@ impl IpfsClient { /// Returns bitswap stats. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.stats_bitswap(); - /// # } + /// let res = client.stats_bitswap(); /// ``` /// #[inline] @@ -2190,14 +1915,10 @@ impl IpfsClient { /// Returns bandwidth stats. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.stats_bw(); - /// # } + /// let res = client.stats_bw(); /// ``` /// #[inline] @@ -2208,14 +1929,10 @@ impl IpfsClient { /// Returns repo stats. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.stats_repo(); - /// # } + /// let res = client.stats_repo(); /// ``` /// #[inline] @@ -2228,14 +1945,10 @@ impl IpfsClient { /// Return a list of local addresses. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.swarm_addrs_local(); - /// # } + /// let res = client.swarm_addrs_local(); /// ``` /// #[inline] @@ -2254,14 +1967,10 @@ impl IpfsClient { /// Return a list of peers with open connections. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.swarm_peers(); - /// # } + /// let res = client.swarm_peers(); /// ``` /// #[inline] @@ -2275,16 +1984,12 @@ impl IpfsClient { /// an error. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// use std::fs::File; /// - /// # fn main() { /// let client = IpfsClient::default(); /// let tar = File::open("/path/to/file.tar").unwrap(); - /// let req = client.tar_add(tar); - /// # } + /// let res = client.tar_add(tar); /// ``` /// #[inline] @@ -2302,14 +2007,10 @@ impl IpfsClient { /// Export a tar file from Ipfs. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.tar_cat("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY"); - /// # } + /// let res = client.tar_cat("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY"); /// ``` /// #[inline] @@ -2320,14 +2021,10 @@ impl IpfsClient { /// Returns information about the Ipfs server version. /// /// ```no_run - /// # extern crate ipfs_api; - /// # /// use ipfs_api::IpfsClient; /// - /// # fn main() { /// let client = IpfsClient::default(); - /// let req = client.version(); - /// # } + /// let res = client.version(); /// ``` /// #[inline] diff --git a/ipfs-api/src/lib.rs b/ipfs-api/src/lib.rs index 03f43c3..3c638de 100644 --- a/ipfs-api/src/lib.rs +++ b/ipfs-api/src/lib.rs @@ -31,54 +31,37 @@ //! #### With Hyper //! //! ```no_run -//! # extern crate hyper; -//! # extern crate ipfs_api; -//! # -//! use hyper::rt::Future; //! use ipfs_api::IpfsClient; //! use std::io::Cursor; //! -//! # fn main() { -//! let client = IpfsClient::default(); -//! let data = Cursor::new("Hello World!"); +//! #[tokio::main] +//! async fn main() { +//! let client = IpfsClient::default(); +//! let data = Cursor::new("Hello World!"); //! -//! let req = client -//! .add(data) -//! .map(|res| { -//! println!("{}", res.hash); -//! }) -//! .map_err(|e| eprintln!("{}", e)); -//! -//! # #[cfg(feature = "hyper")] -//! hyper::rt::run(req); -//! # } +//! match client.add(data).await { +//! Ok(res) => println!("{}", res.hash), +//! Err(e) => eprintln!("error adding file: {}", e) +//! } +//! } //! ``` //! //! #### With Actix //! //! ```no_run -//! # extern crate actix_rt; -//! # extern crate futures; -//! # extern crate ipfs_api; -//! # -//! use futures::future::{Future, lazy}; //! use ipfs_api::IpfsClient; //! use std::io::Cursor; //! -//! # fn main() { -//! let client = IpfsClient::default(); -//! let data = Cursor::new("Hello World!"); -//! -//! let req = client -//! .add(data) -//! .map(|res| { -//! println!("{}", res.hash); -//! }) -//! .map_err(|e| eprintln!("{}", e)); +//! #[actix_rt::main] +//! async fn main() { +//! let client = IpfsClient::default(); +//! let data = Cursor::new("Hello World!"); //! -//! # #[cfg(feature = "actix")] -//! actix_rt::System::new("test").block_on(req); -//! # } +//! match client.add(data).await { +//! Ok(res) => println!("{}", res.hash), +//! Err(e) => eprintln!("error adding file: {}", e) +//! } +//! } //! ``` //! //! ### Reading a file from IPFS @@ -86,61 +69,57 @@ //! #### With Hyper //! //! ```no_run -//! # extern crate futures; -//! # extern crate hyper; -//! # extern crate ipfs_api; -//! # -//! use futures::{Future, Stream}; +//! use futures::TryStreamExt; //! use ipfs_api::IpfsClient; //! use std::io::{self, Write}; //! -//! # fn main() { -//! let client = IpfsClient::default(); -//! -//! let req = client -//! .get("/test/file.json") -//! .concat2() -//! .map(|res| { -//! let out = io::stdout(); -//! let mut out = out.lock(); -//! -//! out.write_all(&res).unwrap(); -//! }) -//! .map_err(|e| eprintln!("{}", e)); -//! -//! # #[cfg(feature = "hyper")] -//! hyper::rt::run(req); -//! # } +//! #[tokio::main] +//! async fn main() { +//! let client = IpfsClient::default(); +//! +//! match client +//! .get("/test/file.json") +//! .map_ok(|chunk| chunk.to_vec()) +//! .try_concat() +//! .await +//! { +//! Ok(res) => { +//! let out = io::stdout(); +//! let mut out = out.lock(); +//! +//! out.write_all(&res).unwrap(); +//! } +//! Err(e) => eprintln!("error getting file: {}", e) +//! } +//! } //! ``` //! //! #### With Actix //! //! ```no_run -//! # extern crate actix_rt; -//! # extern crate futures; -//! # extern crate ipfs_api; -//! # -//! use futures::{Future, lazy, Stream}; +//! use futures::TryStreamExt; //! use ipfs_api::IpfsClient; //! use std::io::{self, Write}; //! -//! # fn main() { -//! let client = IpfsClient::default(); -//! -//! let req = client -//! .get("/test/file.json") -//! .concat2() -//! .map(|res| { -//! let out = io::stdout(); -//! let mut out = out.lock(); -//! -//! out.write_all(&res).unwrap(); -//! }) -//! .map_err(|e| eprintln!("{}", e)); -//! -//! # #[cfg(feature = "actix")] -//! actix_rt::System::new("test").block_on(req); -//! # } +//! #[actix_rt::main] +//! async fn main() { +//! let client = IpfsClient::default(); +//! +//! match client +//! .get("/test/file.json") +//! .map_ok(|chunk| chunk.to_vec()) +//! .try_concat() +//! .await +//! { +//! Ok(res) => { +//! let out = io::stdout(); +//! let mut out = out.lock(); +//! +//! out.write_all(&res).unwrap(); +//! } +//! Err(e) => eprintln!("error getting file: {}", e) +//! } +//! } //! ``` //! //! ### Additional Examples -- cgit v1.2.3