From 0bb7f70f91c422705804ba1fd14411b8c07e6136 Mon Sep 17 00:00:00 2001 From: Julius Michaelis Date: Thu, 9 Jul 2020 15:19:58 +0900 Subject: ipfs files read/write: add offset, count, parents --- ipfs-api/src/client/internal.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'ipfs-api/src/client/internal.rs') diff --git a/ipfs-api/src/client/internal.rs b/ipfs-api/src/client/internal.rs index 2c0d2af..ef4e9f2 100644 --- a/ipfs-api/src/client/internal.rs +++ b/ipfs-api/src/client/internal.rs @@ -1166,13 +1166,15 @@ impl IpfsClient { /// use ipfs_api::IpfsClient; /// /// let client = IpfsClient::default(); - /// let res = client.files_read("/test/file.json"); + /// let res = client.files_read("/test/file.json", 0, None); /// ``` /// + /// Not specifying a byte `count` reads to the end of the file. + /// #[inline] - pub fn files_read(&self, path: &str) -> impl Stream> { + pub fn files_read(&self, path: &str, offset: i64, count: Option) -> impl Stream> { impl_stream_api_response! { - (self, request::FilesRead { path }, None) => request_stream_bytes + (self, request::FilesRead { path, offset, count }, None) => request_stream_bytes } } @@ -1218,15 +1220,20 @@ impl IpfsClient { /// /// let client = IpfsClient::default(); /// let file = File::open("test.json").unwrap(); - /// let res = client.files_write("/test/file.json", true, true, file); + /// let res = client.files_write("/test/file.json", true, true, true, 0, None, file); /// ``` /// + /// Not specifying a byte `count` writes the entire input. + /// #[inline] pub async fn files_write( &self, path: &str, create: bool, truncate: bool, + parents: bool, + offset: i64, + count: Option, data: R, ) -> Result where @@ -1241,6 +1248,9 @@ impl IpfsClient { path, create, truncate, + parents, + offset, + count, }, Some(form), ) -- cgit v1.2.3