ipfs_api_prelude/request/
dht.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 DhtFindPeer<'a> {
14    #[serde(rename = "arg")]
15    pub peer: &'a str,
16}
17
18impl<'a> ApiRequest for DhtFindPeer<'a> {
19    const PATH: &'static str = "/dht/findpeer";
20}
21
22#[derive(Serialize)]
23pub struct DhtFindProvs<'a> {
24    #[serde(rename = "arg")]
25    pub key: &'a str,
26}
27
28impl<'a> ApiRequest for DhtFindProvs<'a> {
29    const PATH: &'static str = "/dht/findprovs";
30}
31
32#[derive(Serialize)]
33pub struct DhtGet<'a> {
34    #[serde(rename = "arg")]
35    pub key: &'a str,
36}
37
38impl<'a> ApiRequest for DhtGet<'a> {
39    const PATH: &'static str = "/dht/get";
40}
41
42#[derive(Serialize)]
43pub struct DhtProvide<'a> {
44    #[serde(rename = "arg")]
45    pub key: &'a str,
46}
47
48impl<'a> ApiRequest for DhtProvide<'a> {
49    const PATH: &'static str = "/dht/provide";
50}
51
52#[derive(Serialize)]
53pub struct DhtPut<'a> {
54    #[serde(rename = "arg")]
55    pub key: &'a str,
56
57    #[serde(rename = "arg")]
58    pub value: &'a str,
59}
60
61impl<'a> ApiRequest for DhtPut<'a> {
62    const PATH: &'static str = "/dht/put";
63}
64
65#[derive(Serialize)]
66pub struct DhtQuery<'a> {
67    #[serde(rename = "arg")]
68    pub peer: &'a str,
69}
70
71impl<'a> ApiRequest for DhtQuery<'a> {
72    const PATH: &'static str = "/dht/query";
73}