summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Michaelis <gitter@liftm.de>2020-07-09 17:33:12 +0900
committerJulius Michaelis <gitter@liftm.de>2020-07-09 20:52:30 +0900
commit27069656be40081303b7e3888b37b5c23231c5df (patch)
treef38bf2b767b67926779494eb9366669c4e2f202b
parent0bb7f70f91c422705804ba1fd14411b8c07e6136 (diff)
add ipfs files chcid
-rw-r--r--ipfs-api/src/client/internal.rs24
-rw-r--r--ipfs-api/src/request/files.rs16
-rw-r--r--ipfs-api/src/response/files.rs2
3 files changed, 42 insertions, 0 deletions
diff --git a/ipfs-api/src/client/internal.rs b/ipfs-api/src/client/internal.rs
index ef4e9f2..6c646cc 100644
--- a/ipfs-api/src/client/internal.rs
+++ b/ipfs-api/src/client/internal.rs
@@ -1257,6 +1257,30 @@ impl IpfsClient {
.await
}
+ /// Change the cid version or hash function of the root node of a given path.
+ ///
+ /// ```no_run
+ /// use ipfs_api::IpfsClient;
+ /// use std::fs::File;
+ ///
+ /// let client = IpfsClient::default();
+ /// let res = client.files_chcid("/test/", 1, Some("sha3-512"));
+ /// ```
+ ///
+ /// Not specifying a byte `count` writes the entire input.
+ ///
+ #[inline]
+ pub async fn files_chcid(
+ &self,
+ path: &str,
+ cid_version: i32,
+ hash: Option<&str>,
+ ) -> Result<response::FilesChcidResponse, Error>
+ {
+ self.request_empty(request::FilesChcid { path, cid_version, hash }, None)
+ .await
+ }
+
/// List blocks that are both in the filestore and standard block storage.
///
/// ```no_run
diff --git a/ipfs-api/src/request/files.rs b/ipfs-api/src/request/files.rs
index 564bd6c..6525a11 100644
--- a/ipfs-api/src/request/files.rs
+++ b/ipfs-api/src/request/files.rs
@@ -124,3 +124,19 @@ pub struct FilesWrite<'a> {
impl<'a> ApiRequest for FilesWrite<'a> {
const PATH: &'static str = "/files/write";
}
+
+#[derive(Serialize)]
+pub struct FilesChcid<'a> {
+ #[serde(rename = "arg")]
+ pub path: &'a str,
+
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub hash: Option<&'a str>,
+
+ #[serde(rename = "cid-version")]
+ pub cid_version: i32,
+}
+
+impl<'a> ApiRequest for FilesChcid<'a> {
+ const PATH: &'static str = "/files/chcid";
+}
diff --git a/ipfs-api/src/response/files.rs b/ipfs-api/src/response/files.rs
index 069ba32..76dc4a1 100644
--- a/ipfs-api/src/response/files.rs
+++ b/ipfs-api/src/response/files.rs
@@ -54,6 +54,8 @@ pub struct FilesStatResponse {
pub type FilesWriteResponse = ();
+pub type FilesChcidResponse = ();
+
#[cfg(test)]
mod tests {
deserialize_test!(v0_files_ls_0, FilesLsResponse);