1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
use request::ApiRequest;
use serde::ser::{Serialize, Serializer};
#[derive(Copy, Clone)]
pub enum KeyType {
Rsa,
Ed25519,
}
impl Serialize for KeyType {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let s = match self {
&KeyType::Rsa => "rsa",
&KeyType::Ed25519 => "ed25519",
};
serializer.serialize_str(s)
}
}
#[derive(Serialize)]
pub struct KeyGen<'a> {
#[serde(rename = "arg")]
pub name: &'a str,
#[serde(rename = "type")]
pub kind: KeyType,
pub size: i32,
}
impl<'a> ApiRequest for KeyGen<'a> {
const PATH: &'static str = "/key/gen";
}
pub struct KeyList;
impl_skip_serialize!(KeyList);
impl ApiRequest for KeyList {
const PATH: &'static str = "/key/list";
}
#[derive(Serialize)]
pub struct KeyRename<'a, 'b> {
#[serde(rename = "arg")]
pub name: &'a str,
#[serde(rename = "arg")]
pub new: &'b str,
pub force: bool,
}
impl<'a, 'b> ApiRequest for KeyRename<'a, 'b> {
const PATH: &'static str = "/key/rename";
}
#[derive(Serialize)]
pub struct KeyRm<'a> {
#[serde(rename = "arg")]
pub name: &'a str,
}
impl<'a> ApiRequest for KeyRm<'a> {
const PATH: &'static str = "/key/rm";
}