From 7a386ef41c5666dc98e75b5cec60f9f48e4450ae Mon Sep 17 00:00:00 2001 From: Julius Michaelis Date: Thu, 9 Jul 2020 20:41:11 +0900 Subject: add ipfs files stat --with-local --- ipfs-api/examples/mfs.rs | 4 ++-- ipfs-api/src/client/internal.rs | 6 +++--- ipfs-api/src/request/files.rs | 3 +++ ipfs-api/src/response/files.rs | 5 +++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ipfs-api/examples/mfs.rs b/ipfs-api/examples/mfs.rs index b53935c..2b20111 100644 --- a/ipfs-api/examples/mfs.rs +++ b/ipfs-api/examples/mfs.rs @@ -47,7 +47,7 @@ async fn main() { eprintln!("getting status of /test/does..."); eprintln!(); - match client.files_stat("/test/does").await { + match client.files_stat("/test/does", false).await { Ok(stat) => print_stat(stat), Err(e) => { eprintln!("error getting status of /test/does: {}", e); @@ -68,7 +68,7 @@ async fn main() { eprintln!("getting status of /test/mfs.rs..."); eprintln!(); - match client.files_stat("/test/mfs.rs").await { + match client.files_stat("/test/mfs.rs", false).await { Ok(stat) => print_stat(stat), Err(e) => { eprintln!("error getting status of /test/mfs.rs: {}", e); diff --git a/ipfs-api/src/client/internal.rs b/ipfs-api/src/client/internal.rs index f317fe8..8eaf595 100644 --- a/ipfs-api/src/client/internal.rs +++ b/ipfs-api/src/client/internal.rs @@ -1210,12 +1210,12 @@ impl IpfsClient { /// use ipfs_api::IpfsClient; /// /// let client = IpfsClient::default(); - /// let res = client.files_stat("/test/file.json"); + /// let res = client.files_stat("/test/file.json", false); /// ``` /// #[inline] - pub async fn files_stat(&self, path: &str) -> Result { - self.request(request::FilesStat { path }, None).await + pub async fn files_stat(&self, path: &str, with_local: bool) -> Result { + self.request(request::FilesStat { path, with_local }, None).await } /// Write to a mutable file in the filesystem. diff --git a/ipfs-api/src/request/files.rs b/ipfs-api/src/request/files.rs index e70e04b..b4b148f 100644 --- a/ipfs-api/src/request/files.rs +++ b/ipfs-api/src/request/files.rs @@ -112,6 +112,9 @@ impl<'a> ApiRequest for FilesRm<'a> { pub struct FilesStat<'a> { #[serde(rename = "arg")] pub path: &'a str, + + #[serde(rename = "with-local")] + pub with_local: bool, } impl<'a> ApiRequest for FilesStat<'a> { diff --git a/ipfs-api/src/response/files.rs b/ipfs-api/src/response/files.rs index 76dc4a1..f27be1f 100644 --- a/ipfs-api/src/response/files.rs +++ b/ipfs-api/src/response/files.rs @@ -50,6 +50,11 @@ pub struct FilesStatResponse { #[serde(rename = "Type")] pub typ: String, + + #[serde(default)] + pub size_local: Option, + #[serde(default)] + pub local: Option, } pub type FilesWriteResponse = (); -- cgit v1.2.3