ipfs_api_prelude/response/
repo.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;
11use std::collections::HashMap;
12
13#[derive(Deserialize)]
14#[serde(rename_all = "PascalCase")]
15pub struct RepoFsckResponse {
16    pub message: String,
17}
18
19#[derive(Deserialize)]
20#[serde(rename_all = "PascalCase")]
21pub struct RepoGcResponse {
22    #[serde(deserialize_with = "serde::deserialize_hashmap")]
23    pub key: HashMap<String, String>,
24    pub error: Option<String>,
25}
26
27#[derive(Debug, Deserialize)]
28#[serde(rename_all = "PascalCase")]
29pub struct RepoStatResponse {
30    pub num_objects: u64,
31    pub repo_size: u64,
32    pub repo_path: String,
33    pub version: String,
34}
35
36// Defined in go-ipfs:master core/commands/repo.go
37#[derive(Deserialize)]
38#[serde(rename_all = "PascalCase")]
39pub struct RepoVerifyResponse {
40    pub message: String,
41    // Could technically be an i64 but this is probably safest?
42    pub progress: i32,
43}
44
45#[derive(Deserialize)]
46#[serde(rename_all = "PascalCase")]
47pub struct RepoVersionResponse {
48    pub version: String,
49}
50
51#[cfg(test)]
52mod tests {
53    deserialize_test!(v0_repo_gc_0, RepoGcResponse);
54    deserialize_test!(v0_repo_stat_0, RepoStatResponse);
55    deserialize_test!(v0_repo_verify_0, RepoVerifyResponse);
56    deserialize_test!(v0_repo_verify_1, RepoVerifyResponse);
57    deserialize_test!(v0_repo_version_0, RepoVersionResponse);
58}