ipfs_api_prelude/request/
add.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#[cfg_attr(feature = "with-builder", derive(TypedBuilder))]
13#[derive(Serialize, Default)]
14#[serde(rename_all = "kebab-case")]
15pub struct Add<'a> {
16    /// Use trickle-dag format for dag generation.
17    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
18    pub trickle: Option<bool>,
19
20    /// Only chunk and hash - do not write to disk.
21    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
22    pub only_hash: Option<bool>,
23
24    /// Wrap files with a directory object.
25    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
26    pub wrap_with_directory: Option<bool>,
27
28    /// Chunking algorithm, `size-[bytes]`, `rabin-[min]-[avg]-[max]` or `buzhash`.
29    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
30    pub chunker: Option<&'a str>,
31
32    /// Pin this object when adding. Defaults to `true`.
33    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
34    pub pin: Option<bool>,
35
36    /// Use raw blocks for leaf nodes. (experimental).
37    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
38    pub raw_leaves: Option<bool>,
39
40    /// CID version. Defaults to 0 unless an option that depends on CIDv1 is passed.
41    /// (experimental).
42    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
43    pub cid_version: Option<u32>,
44
45    /// Hash function to use. Implies CIDv1 if not sha2-256. (experimental). Default:
46    /// `sha2-256`.
47    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
48    pub hash: Option<&'a str>,
49
50    /// Inline small blocks into CIDs. (experimental).
51    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
52    pub inline: Option<bool>,
53
54    /// Maximum block size to inline. (experimental). Default: `32`.
55    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
56    pub inline_limit: Option<u32>,
57
58    ///  Add reference to Files API (MFS) at the provided path
59    #[cfg_attr(feature = "with-builder", builder(default, setter(strip_option)))]
60    pub to_files: Option<&'a str>,
61}
62
63impl<'a> ApiRequest for Add<'a> {
64    const PATH: &'static str = "/add";
65}