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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
use super::Call;
use std::collections::BTreeMap;
use std::fmt;
/// The DNS record type.
#[derive(Clone, Copy, Debug)]
pub enum RecordType {
A,
Aaaa,
Afsdb,
Alias,
Caa,
Cert,
Cname,
Hinfo,
Key,
Loc,
Mx,
NaPtr,
Ns,
OpenPgpKey,
Ptr,
Rp,
SmimeA,
Soa,
Srv,
Sshfp,
Tlsa,
Txt,
Uri,
Url,
}
impl fmt::Display for RecordType {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
RecordType::A => write!(fmt, "A"),
RecordType::Aaaa => write!(fmt, "AAAA"),
RecordType::Afsdb => write!(fmt, "AFSDB"),
RecordType::Alias => write!(fmt, "ALIAS"),
RecordType::Caa => write!(fmt, "CAA"),
RecordType::Cert => write!(fmt, "CERT"),
RecordType::Cname => write!(fmt, "CNAME"),
RecordType::Hinfo => write!(fmt, "HINFO"),
RecordType::Key => write!(fmt, "KEY"),
RecordType::Loc => write!(fmt, "LOC"),
RecordType::Mx => write!(fmt, "MX"),
RecordType::NaPtr => write!(fmt, "NAPTR"),
RecordType::Ns => write!(fmt, "NS"),
RecordType::OpenPgpKey => write!(fmt, "OPENPGPKEY"),
RecordType::Ptr => write!(fmt, "PTR"),
RecordType::Rp => write!(fmt, "RP"),
RecordType::SmimeA => write!(fmt, "SMIMEA"),
RecordType::Soa => write!(fmt, "SOA"),
RecordType::Srv => write!(fmt, "SRV"),
RecordType::Sshfp => write!(fmt, "SSHFP"),
RecordType::Tlsa => write!(fmt, "TLSA"),
RecordType::Txt => write!(fmt, "TXT"),
RecordType::Uri => write!(fmt, "URI"),
RecordType::Url => write!(fmt, "URL"),
}
}
}
impl From<RecordType> for xmlrpc::Value {
fn from(rt: RecordType) -> Self {
xmlrpc::Value::String(rt.to_string())
}
}
/// Search parameters to find nameserver records
/// the account has access to.
#[derive(Clone, Copy, Debug)]
pub struct RecordInfo<'a> {
pub domain_name: &'a str,
pub domain_id: i32,
pub record_id: i32,
pub record_type: RecordType,
pub name: &'a str,
pub content: &'a str,
pub ttl: i32,
pub priority: i32,
}
impl From<RecordInfo<'_>> for xmlrpc::Value {
fn from(info: RecordInfo<'_>) -> Self {
let mut map = BTreeMap::new();
map.insert("domain".into(), info.domain_name.into());
map.insert("roId".into(), info.domain_id.into());
map.insert("recordId".into(), info.record_id.into());
map.insert("type".into(), info.record_type.into());
map.insert("content".into(), info.content.into());
map.insert("ttl".into(), info.ttl.into());
map.insert("prio".into(), info.priority.into());
xmlrpc::Value::Struct(map)
}
}
impl Call for RecordInfo<'_> {
fn method_name(&self) -> &'static str {
"nameserver.info"
}
fn expected(&self) -> &'static [i32] {
&[1000]
}
}
|