ipfs_api_prelude/response/
dag.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(Debug, Deserialize)]
14#[serde(rename_all = "PascalCase")]
15pub struct DagIpfsHeader {
16    pub name: String,
17    pub size: u64,
18
19    #[serde(deserialize_with = "serde::deserialize_hashmap")]
20    pub cid: HashMap<String, String>,
21}
22
23#[derive(Debug, Deserialize)]
24pub struct DagGetResponse {
25    pub data: Option<String>,
26
27    #[serde(deserialize_with = "serde::deserialize_vec")]
28    pub links: Vec<DagIpfsHeader>,
29}
30
31#[derive(Debug, Deserialize)]
32pub struct DagPutResponse {
33    #[serde(rename = "Cid")]
34    pub cid: Cid,
35}
36
37#[derive(Debug, Deserialize)]
38pub struct Cid {
39    #[serde(rename = "/")]
40    pub cid_string: String,
41}
42
43#[cfg(test)]
44mod tests {
45    deserialize_test!(v0_dag_get_0, DagGetResponse);
46}