diff options
author | Julius Michaelis <gitter@liftm.de> | 2020-10-24 19:21:29 +0900 |
---|---|---|
committer | Julius Michaelis <gitter@liftm.de> | 2020-10-24 20:21:53 +0900 |
commit | eabde517363495d4f5c2962cce61878c3d047593 (patch) | |
tree | 791528495f5680114636af2b914a1e7246e164f1 /ipfs-api/src/client/internal.rs | |
parent | 38e8ad75e9310beac9846f982eecb7a0ba439bbd (diff) |
ls_with_options
Diffstat (limited to 'ipfs-api/src/client/internal.rs')
-rw-r--r-- | ipfs-api/src/client/internal.rs | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/ipfs-api/src/client/internal.rs b/ipfs-api/src/client/internal.rs index 7ee856b..607f4c1 100644 --- a/ipfs-api/src/client/internal.rs +++ b/ipfs-api/src/client/internal.rs @@ -1942,13 +1942,47 @@ impl IpfsClient { /// use ipfs_api::IpfsClient; /// /// let client = IpfsClient::default(); - /// let res = client.ls(None); /// let res = client.ls(Some("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY")); /// ``` /// #[inline] pub async fn ls(&self, path: Option<&str>) -> Result<response::LsResponse, Error> { - self.request(request::Ls { path }, None).await + self.request(request::Ls { + path: path.expect("Path is not actually optional"), + stream: None, + resolve_type: None, + size: None, + }, None).await + } + + /// List the contents of an Ipfs multihash. + /// + /// ```no_run + /// use ipfs_api::IpfsClient; + /// + /// let client = IpfsClient::default(); + /// #[cfg(feature = "builder")] + /// let _ = client.ls_with_options(ipfs_api::request::Ls::builder() + /// .path("/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n") + /// .build() + /// ); + /// let _ = client.ls_with_options(ipfs_api::request::Ls { + /// path: "/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n", + /// // Example options for fast listing + /// stream: Some(true), + /// resolve_type: Some(false), + /// size: Some(false), + /// }); + /// ``` + /// + #[inline] + pub async fn ls_with_options( + &self, + options: request::Ls<'_> + ) -> impl Stream<Item = Result<response::LsResponse, Error>> { + impl_stream_api_response! { + (self, options, None) => request_stream_json + } } // TODO /mount |