ipfs_api_prelude/response/
mod.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
9//! This module contains structures returned by the IPFS API.
10
11use crate::serde::Deserialize;
12
13pub use self::add::*;
14pub use self::bitswap::*;
15pub use self::block::*;
16pub use self::bootstrap::*;
17pub use self::commands::*;
18pub use self::config::*;
19pub use self::dag::*;
20pub use self::dht::*;
21pub use self::diag::*;
22pub use self::dns::*;
23pub use self::error::*;
24pub use self::file::*;
25pub use self::files::*;
26pub use self::filestore::*;
27pub use self::id::*;
28pub use self::key::*;
29pub use self::log::*;
30pub use self::ls::*;
31pub use self::mount::*;
32pub use self::name::*;
33pub use self::object::*;
34pub use self::pin::*;
35pub use self::ping::*;
36pub use self::pubsub::*;
37pub use self::refs::*;
38pub use self::repo::*;
39pub use self::resolve::*;
40pub use self::shutdown::*;
41pub use self::stats::*;
42pub use self::swarm::*;
43pub use self::swarm_connect::*;
44pub use self::tar::*;
45pub use self::version::*;
46
47/// Create a test to deserialize a file to the given instance.
48///
49#[cfg(test)]
50macro_rules! deserialize_test {
51    ($f: ident, $ty: ident) => {
52        #[test]
53        fn $f() {
54            let raw = include_str!(concat!("tests/", stringify!($f), ".json"));
55
56            match ::serde_json::from_str::<super::$ty>(raw) {
57                Ok(_) => assert!(true),
58                Err(e) => assert!(false, "failed with error: {}", e),
59            };
60        }
61    };
62}
63
64mod add;
65mod bitswap;
66mod block;
67mod bootstrap;
68mod commands;
69mod config;
70mod dag;
71mod dht;
72mod diag;
73mod dns;
74mod error;
75mod file;
76mod files;
77mod filestore;
78mod id;
79mod key;
80mod log;
81mod ls;
82mod mount;
83mod name;
84mod object;
85mod pin;
86mod ping;
87mod pubsub;
88mod refs;
89mod repo;
90mod resolve;
91mod serde;
92mod shutdown;
93mod stats;
94mod swarm;
95mod swarm_connect;
96mod tar;
97mod version;
98
99#[derive(Debug, Deserialize)]
100#[serde(rename_all = "PascalCase")]
101pub struct IpfsHeader {
102    pub name: String,
103    pub hash: String,
104    pub size: u64,
105
106    #[serde(rename = "Type")]
107    pub typ: Option<String>,
108}