ipfs_api_prelude/request/
block.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::request::ApiRequest;
10use serde::Serialize;
11
12#[derive(Serialize)]
13pub struct BlockGet<'a> {
14    #[serde(rename = "arg")]
15    pub hash: &'a str,
16}
17
18impl<'a> ApiRequest for BlockGet<'a> {
19    const PATH: &'static str = "/block/get";
20}
21
22#[cfg_attr(feature = "with-builder", derive(TypedBuilder))]
23#[derive(Serialize, Default)]
24#[serde(rename_all = "kebab-case")]
25pub struct BlockPut<'a> {
26    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
27    pub format: Option<&'a str>,
28    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
29    pub mhtype: Option<&'a str>,
30    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
31    pub mhlen: Option<u32>,
32    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
33    pub pin: Option<bool>,
34}
35
36impl<'a> ApiRequest for BlockPut<'a> {
37    const PATH: &'static str = "/block/put";
38}
39
40#[derive(Serialize)]
41pub struct BlockRm<'a> {
42    #[serde(rename = "arg")]
43    pub hash: &'a str,
44}
45
46impl<'a> ApiRequest for BlockRm<'a> {
47    const PATH: &'static str = "/block/rm";
48}
49
50#[derive(Serialize)]
51pub struct BlockStat<'a> {
52    #[serde(rename = "arg")]
53    pub hash: &'a str,
54}
55
56impl<'a> ApiRequest for BlockStat<'a> {
57    const PATH: &'static str = "/block/stat";
58}