summaryrefslogtreecommitdiffstats
path: root/ipfs-api/src/client/internal.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ipfs-api/src/client/internal.rs')
-rw-r--r--ipfs-api/src/client/internal.rs93
1 files changed, 71 insertions, 22 deletions
diff --git a/ipfs-api/src/client/internal.rs b/ipfs-api/src/client/internal.rs
index 475ec17..885f6a4 100644
--- a/ipfs-api/src/client/internal.rs
+++ b/ipfs-api/src/client/internal.rs
@@ -1113,7 +1113,7 @@ impl IpfsClient {
/// use ipfs_api::IpfsClient;
///
/// let client = IpfsClient::default();
- /// let res = client.files_cp("/path/to/file", "/dest");
+ /// let res = client.files_cp("/path/to/file", "/dest", true);
/// ```
///
#[inline]
@@ -1121,8 +1121,9 @@ impl IpfsClient {
&self,
path: &str,
dest: &str,
+ flush: bool,
) -> Result<response::FilesCpResponse, Error> {
- self.request_empty(request::FilesCp { path, dest }, None)
+ self.request_empty(request::FilesCp { path, dest, flush }, None)
.await
}
@@ -1144,19 +1145,19 @@ impl IpfsClient {
self.request_empty(request::FilesFlush { path }, None).await
}
- /// List directories in MFS.
+ /// List directories in MFS. Always passes `-U`.
///
/// ```no_run
/// use ipfs_api::IpfsClient;
///
/// let client = IpfsClient::default();
- /// let res = client.files_ls(None);
- /// let res = client.files_ls(Some("/tmp"));
+ /// let res = client.files_ls(None, false);
+ /// let res = client.files_ls(Some("/tmp"), true);
/// ```
///
#[inline]
- pub async fn files_ls(&self, path: Option<&str>) -> Result<response::FilesLsResponse, Error> {
- self.request(request::FilesLs { path }, None).await
+ pub async fn files_ls(&self, path: Option<&str>, long: bool) -> Result<response::FilesLsResponse, Error> {
+ self.request(request::FilesLs { path, long, unsorted: true }, None).await
}
/// Make directories in MFS.
@@ -1165,8 +1166,8 @@ impl IpfsClient {
/// use ipfs_api::IpfsClient;
///
/// let client = IpfsClient::default();
- /// let res = client.files_mkdir("/test", false);
- /// let res = client.files_mkdir("/test/nested/dir", true);
+ /// let res = client.files_mkdir("/test", false, 0, None, true);
+ /// let res = client.files_mkdir("/test/nested/dir", true, 0, None, true);
/// ```
///
#[inline]
@@ -1174,8 +1175,11 @@ impl IpfsClient {
&self,
path: &str,
parents: bool,
+ cid_version: i32,
+ hash: Option<&str>,
+ flush: bool,
) -> Result<response::FilesMkdirResponse, Error> {
- self.request_empty(request::FilesMkdir { path, parents }, None)
+ self.request_empty(request::FilesMkdir { path, parents, cid_version, hash, flush }, None)
.await
}
@@ -1185,7 +1189,7 @@ impl IpfsClient {
/// use ipfs_api::IpfsClient;
///
/// let client = IpfsClient::default();
- /// let res = client.files_mv("/test/tmp.json", "/test/file.json");
+ /// let res = client.files_mv("/test/tmp.json", "/test/file.json", true);
/// ```
///
#[inline]
@@ -1193,8 +1197,9 @@ impl IpfsClient {
&self,
path: &str,
dest: &str,
+ flush: bool,
) -> Result<response::FilesMvResponse, Error> {
- self.request_empty(request::FilesMv { path, dest }, None)
+ self.request_empty(request::FilesMv { path, dest, flush }, None)
.await
}
@@ -1204,13 +1209,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<Item = Result<Bytes, Error>> {
+ pub fn files_read(&self, path: &str, offset: i64, count: Option<i64>) -> impl Stream<Item = Result<Bytes, Error>> {
impl_stream_api_response! {
- (self, request::FilesRead { path }, None) => request_stream_bytes
+ (self, request::FilesRead { path, offset, count }, None) => request_stream_bytes
}
}
@@ -1220,8 +1227,8 @@ impl IpfsClient {
/// use ipfs_api::IpfsClient;
///
/// let client = IpfsClient::default();
- /// let res = client.files_rm("/test/dir", true);
- /// let res = client.files_rm("/test/file.json", false);
+ /// let res = client.files_rm("/test/dir", true, true);
+ /// let res = client.files_rm("/test/file.json", false, true);
/// ```
///
#[inline]
@@ -1229,8 +1236,9 @@ impl IpfsClient {
&self,
path: &str,
recursive: bool,
+ flush: bool,
) -> Result<response::FilesRmResponse, Error> {
- self.request_empty(request::FilesRm { path, recursive }, None)
+ self.request_empty(request::FilesRm { path, recursive, flush }, None)
.await
}
@@ -1240,12 +1248,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<response::FilesStatResponse, Error> {
- self.request(request::FilesStat { path }, None).await
+ pub async fn files_stat(&self, path: &str, with_local: bool) -> Result<response::FilesStatResponse, Error> {
+ self.request(request::FilesStat { path, with_local }, None).await
}
/// Write to a mutable file in the filesystem.
@@ -1256,15 +1264,24 @@ 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, false, 0, None, true, file);
/// ```
///
+ /// Not specifying a byte `count` writes the entire input.
+ ///
#[inline]
pub async fn files_write<R>(
&self,
path: &str,
create: bool,
truncate: bool,
+ parents: bool,
+ offset: i64,
+ count: Option<i64>,
+ raw_leaves: bool,
+ cid_version: i32,
+ hash: Option<&str>,
+ flush: bool,
data: R,
) -> Result<response::FilesWriteResponse, Error>
where
@@ -1279,12 +1296,44 @@ impl IpfsClient {
path,
create,
truncate,
+ parents,
+ offset,
+ count,
+ raw_leaves,
+ cid_version,
+ hash,
+ flush,
},
Some(form),
)
.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"), true);
+ /// ```
+ ///
+ /// Not specifying a byte `count` writes the entire input.
+ ///
+ #[inline]
+ pub async fn files_chcid(
+ &self,
+ path: &str,
+ cid_version: i32,
+ hash: Option<&str>,
+ flush: bool,
+ ) -> Result<response::FilesChcidResponse, Error>
+ {
+ self.request_empty(request::FilesChcid { path, cid_version, hash, flush }, None)
+ .await
+ }
+
/// List blocks that are both in the filestore and standard block storage.
///
/// ```no_run