ipfs_api_prelude/response/
files.rs

1// Copyright 2017 rust-ipfs-api Developers
2//
3// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5// http://opensource.org/licenses/MIT>, at your option. This file may not be
6// copied, modified, or distributed except according to those terms.
7//
8
9use crate::response::serde;
10use crate::serde::Deserialize;
11
12pub type FilesCpResponse = ();
13
14pub type FilesFlushResponse = ();
15
16#[derive(Debug, Deserialize)]
17#[serde(rename_all = "PascalCase")]
18pub struct FilesEntry {
19    pub name: String,
20
21    // This is a protocol buffer enum type defined in
22    // https://github.com/ipfs/go-ipfs/blob/master/unixfs/pb/unixfs.proto ...
23    // So it might be some other type than u64, but certainly shouldn't be *bigger* than u64.
24    #[serde(rename = "Type")]
25    pub typ: u64,
26    pub size: u64,
27    pub hash: String,
28}
29
30#[derive(Debug, Deserialize)]
31#[serde(rename_all = "PascalCase")]
32pub struct FilesLsResponse {
33    #[serde(deserialize_with = "serde::deserialize_vec")]
34    pub entries: Vec<FilesEntry>,
35}
36
37pub type FilesMkdirResponse = ();
38
39pub type FilesMvResponse = ();
40
41pub type FilesRmResponse = ();
42
43#[derive(Debug, Deserialize)]
44#[serde(rename_all = "PascalCase")]
45pub struct FilesStatResponse {
46    pub hash: String,
47    pub size: u64,
48    pub cumulative_size: u64,
49    pub blocks: u64,
50
51    #[serde(rename = "Type")]
52    pub typ: String,
53
54    #[serde(default)]
55    pub size_local: Option<u64>,
56    #[serde(default)]
57    pub local: Option<bool>,
58}
59
60pub type FilesWriteResponse = ();
61
62pub type FilesChcidResponse = ();
63
64#[cfg(test)]
65mod tests {
66    deserialize_test!(v0_files_ls_0, FilesLsResponse);
67    deserialize_test!(v0_files_stat_0, FilesStatResponse);
68}