summaryrefslogtreecommitdiffstats
path: root/ipfs-api/src
diff options
context:
space:
mode:
authorSionoiS <SionoiS@users.noreply.github.com>2020-08-03 11:17:23 -0400
committerSionoiS <SionoiS@users.noreply.github.com>2020-08-03 11:17:23 -0400
commit82accb206e45beeecef7995238ea6ad9a6c7c42c (patch)
tree8e830f84eaa20de7361a4f69817c0ca526e0ba52 /ipfs-api/src
parent5578f9b3cdf91e4f6c736ee9c2bbc3b408890149 (diff)
dag get return stream & fixes
Diffstat (limited to 'ipfs-api/src')
-rw-r--r--ipfs-api/src/client/internal.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/ipfs-api/src/client/internal.rs b/ipfs-api/src/client/internal.rs
index 6785180..17059fd 100644
--- a/ipfs-api/src/client/internal.rs
+++ b/ipfs-api/src/client/internal.rs
@@ -845,21 +845,29 @@ impl IpfsClient {
/// Returns information about a dag node in Ipfs.
///
/// ```no_run
+ /// use futures::TryStreamExt;
/// use ipfs_api::IpfsClient;
///
/// let client = IpfsClient::default();
- /// let res = client.dag_get("QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA");
+ /// let hash = "QmXdNSQx7nbdRvkjGCEQgVjVtVwsHvV8NmV2a8xzQVwuFA";
+ /// let res = client
+ /// .dag_get(hash)
+ /// .map_ok(|chunk| chunk.to_vec())
+ /// .try_concat();
/// ```
///
#[inline]
- pub async fn dag_get(&self, path: &str) -> Result<String, Error> {
- self.request_string(request::DagGet { path }, None).await
+ pub fn dag_get(&self, path: &str) -> impl Stream<Item = Result<Bytes, Error>> {
+ impl_stream_api_response! {
+ (self, request::DagGet { path }, None) => request_stream_bytes
+ }
}
/// Add a DAG node to Ipfs.
///
/// ```no_run
/// use ipfs_api::IpfsClient;
+ /// use std::io::Cursor;
///
/// let client = IpfsClient::default();
/// let data = Cursor::new(r#"{ "hello" : "world" }"#);