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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
use crate::epp::object::{StringValue, StringValueTrait};
use serde::{Deserialize, Serialize};
pub type DomainStatus = ContactStatus;
pub type HostStatus = ContactStatus;
#[derive(Serialize, Deserialize, Debug)]
pub struct HostAddr {
#[serde(rename = "ip")]
pub ip_version: Option<String>,
#[serde(rename = "$value")]
pub address: String,
}
impl HostAddr {
pub fn new(ip_version: &str, address: &str) -> HostAddr {
HostAddr {
ip_version: Some(ip_version.to_string()),
address: address.to_string(),
}
}
pub fn new_v4(address: &str) -> HostAddr {
HostAddr {
ip_version: Some("v4".to_string()),
address: address.to_string(),
}
}
pub fn new_v6(address: &str) -> HostAddr {
HostAddr {
ip_version: Some("v6".to_string()),
address: address.to_string(),
}
}
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Host {
pub name: StringValue,
#[serde(rename = "addr")]
pub addresses: Option<Vec<HostAddr>>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct HostAttr {
#[serde(rename = "hostName")]
pub name: StringValue,
#[serde(rename = "hostAddr")]
pub addresses: Option<Vec<HostAddr>>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct HostAttrList {
#[serde(rename = "hostAttr")]
pub hosts: Vec<HostAttr>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct HostObjList {
#[serde(rename = "hostObj")]
pub hosts: Vec<StringValue>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct DomainContact {
#[serde(rename = "$value")]
pub id: String,
#[serde(rename = "type")]
pub contact_type: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Period {
unit: String,
#[serde(rename = "$value")]
length: u16,
}
impl Period {
pub fn new(length: u16) -> Period {
Period {
unit: "y".to_string(),
length: length,
}
}
pub fn set_unit(&mut self, unit: &str) {
self.unit = unit.to_string();
}
}
#[derive(Serialize, Deserialize, Debug)]
pub struct ContactStatus {
#[serde(rename = "s")]
pub status: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Phone {
#[serde(rename = "$value")]
pub number: String,
#[serde(rename = "x")]
pub extension: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Address {
pub street: Vec<StringValue>,
pub city: StringValue,
#[serde(rename = "sp")]
pub province: StringValue,
#[serde(rename = "pc")]
pub postal_code: StringValue,
#[serde(rename = "cc")]
pub country_code: StringValue,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PostalInfo {
#[serde(rename = "type")]
pub info_type: String,
pub name: StringValue,
#[serde(rename = "org")]
pub organization: StringValue,
#[serde(rename = "addr")]
pub address: Address,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AuthInfo {
#[serde(rename = "pw")]
pub password: StringValue,
}
impl Phone {
pub fn new(number: &str) -> Phone {
Phone {
extension: None,
number: number.to_string(),
}
}
pub fn set_extension(&mut self, ext: &str) {
self.extension = Some(ext.to_string());
}
}
impl AuthInfo {
pub fn new(password: &str) -> AuthInfo {
AuthInfo {
password: password.to_string_value(),
}
}
}
impl Address {
pub fn new(
street: Vec<&str>,
city: &str,
province: &str,
postal_code: &str,
country_code: &str,
) -> Address {
let street = street
.iter()
.filter_map(|s| Some(s.to_string_value()))
.collect::<Vec<StringValue>>();
Address {
street: street,
city: city.to_string_value(),
province: province.to_string_value(),
postal_code: postal_code.to_string_value(),
country_code: country_code.to_string_value(),
}
}
}
impl PostalInfo {
pub fn new(info_type: &str, name: &str, organization: &str, address: Address) -> PostalInfo {
PostalInfo {
info_type: info_type.to_string(),
name: name.to_string_value(),
organization: organization.to_string_value(),
address: address,
}
}
}