tencent_sdk/types/
newtypes.rs

1use serde::{Deserialize, Serialize};
2use std::fmt;
3
4#[derive(Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
5#[serde(transparent)]
6pub struct Region(String);
7
8impl Region {
9    pub fn new(value: impl Into<String>) -> Self {
10        Self(value.into())
11    }
12
13    pub fn as_str(&self) -> &str {
14        &self.0
15    }
16}
17
18impl fmt::Debug for Region {
19    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20        f.debug_tuple("Region").field(&self.0).finish()
21    }
22}
23
24impl fmt::Display for Region {
25    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26        f.write_str(&self.0)
27    }
28}
29
30impl AsRef<str> for Region {
31    fn as_ref(&self) -> &str {
32        self.as_str()
33    }
34}
35
36impl From<String> for Region {
37    fn from(value: String) -> Self {
38        Self(value)
39    }
40}
41
42impl From<&str> for Region {
43    fn from(value: &str) -> Self {
44        Self(value.to_string())
45    }
46}
47
48#[derive(Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
49#[serde(transparent)]
50pub struct RequestId(String);
51
52impl RequestId {
53    pub fn new(value: impl Into<String>) -> Self {
54        Self(value.into())
55    }
56
57    pub fn as_str(&self) -> &str {
58        &self.0
59    }
60}
61
62impl fmt::Debug for RequestId {
63    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
64        f.debug_tuple("RequestId").field(&self.0).finish()
65    }
66}
67
68impl fmt::Display for RequestId {
69    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
70        f.write_str(&self.0)
71    }
72}
73
74impl AsRef<str> for RequestId {
75    fn as_ref(&self) -> &str {
76        self.as_str()
77    }
78}
79
80impl From<String> for RequestId {
81    fn from(value: String) -> Self {
82        Self(value)
83    }
84}
85
86impl From<&str> for RequestId {
87    fn from(value: &str) -> Self {
88        Self(value.to_string())
89    }
90}
91
92#[derive(Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
93#[serde(transparent)]
94pub struct InstanceId(String);
95
96impl InstanceId {
97    pub fn new(value: impl Into<String>) -> Self {
98        Self(value.into())
99    }
100
101    pub fn as_str(&self) -> &str {
102        &self.0
103    }
104}
105
106impl fmt::Debug for InstanceId {
107    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
108        f.debug_tuple("InstanceId").field(&self.0).finish()
109    }
110}
111
112impl fmt::Display for InstanceId {
113    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
114        f.write_str(&self.0)
115    }
116}
117
118impl AsRef<str> for InstanceId {
119    fn as_ref(&self) -> &str {
120        self.as_str()
121    }
122}
123
124impl From<String> for InstanceId {
125    fn from(value: String) -> Self {
126        Self(value)
127    }
128}
129
130impl From<&str> for InstanceId {
131    fn from(value: &str) -> Self {
132        Self(value.to_string())
133    }
134}
135
136#[derive(Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
137#[serde(transparent)]
138pub struct ImageId(String);
139
140impl ImageId {
141    pub fn new(value: impl Into<String>) -> Self {
142        Self(value.into())
143    }
144
145    pub fn as_str(&self) -> &str {
146        &self.0
147    }
148}
149
150impl fmt::Debug for ImageId {
151    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
152        f.debug_tuple("ImageId").field(&self.0).finish()
153    }
154}
155
156impl fmt::Display for ImageId {
157    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
158        f.write_str(&self.0)
159    }
160}
161
162impl AsRef<str> for ImageId {
163    fn as_ref(&self) -> &str {
164        self.as_str()
165    }
166}
167
168impl From<String> for ImageId {
169    fn from(value: String) -> Self {
170        Self(value)
171    }
172}
173
174impl From<&str> for ImageId {
175    fn from(value: &str) -> Self {
176        Self(value.to_string())
177    }
178}
179
180#[derive(Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
181#[serde(transparent)]
182pub struct VpcId(String);
183
184impl VpcId {
185    pub fn new(value: impl Into<String>) -> Self {
186        Self(value.into())
187    }
188
189    pub fn as_str(&self) -> &str {
190        &self.0
191    }
192}
193
194impl fmt::Debug for VpcId {
195    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
196        f.debug_tuple("VpcId").field(&self.0).finish()
197    }
198}
199
200impl fmt::Display for VpcId {
201    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
202        f.write_str(&self.0)
203    }
204}
205
206impl AsRef<str> for VpcId {
207    fn as_ref(&self) -> &str {
208        self.as_str()
209    }
210}
211
212impl From<String> for VpcId {
213    fn from(value: String) -> Self {
214        Self(value)
215    }
216}
217
218impl From<&str> for VpcId {
219    fn from(value: &str) -> Self {
220        Self(value.to_string())
221    }
222}
223
224#[derive(Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
225#[serde(transparent)]
226pub struct SubnetId(String);
227
228impl SubnetId {
229    pub fn new(value: impl Into<String>) -> Self {
230        Self(value.into())
231    }
232
233    pub fn as_str(&self) -> &str {
234        &self.0
235    }
236}
237
238impl fmt::Debug for SubnetId {
239    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
240        f.debug_tuple("SubnetId").field(&self.0).finish()
241    }
242}
243
244impl fmt::Display for SubnetId {
245    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
246        f.write_str(&self.0)
247    }
248}
249
250impl AsRef<str> for SubnetId {
251    fn as_ref(&self) -> &str {
252        self.as_str()
253    }
254}
255
256impl From<String> for SubnetId {
257    fn from(value: String) -> Self {
258        Self(value)
259    }
260}
261
262impl From<&str> for SubnetId {
263    fn from(value: &str) -> Self {
264        Self(value.to_string())
265    }
266}
267
268#[derive(Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
269#[serde(transparent)]
270pub struct SecurityGroupId(String);
271
272impl SecurityGroupId {
273    pub fn new(value: impl Into<String>) -> Self {
274        Self(value.into())
275    }
276
277    pub fn as_str(&self) -> &str {
278        &self.0
279    }
280}
281
282impl fmt::Debug for SecurityGroupId {
283    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
284        f.debug_tuple("SecurityGroupId").field(&self.0).finish()
285    }
286}
287
288impl fmt::Display for SecurityGroupId {
289    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
290        f.write_str(&self.0)
291    }
292}
293
294impl AsRef<str> for SecurityGroupId {
295    fn as_ref(&self) -> &str {
296        self.as_str()
297    }
298}
299
300impl From<String> for SecurityGroupId {
301    fn from(value: String) -> Self {
302        Self(value)
303    }
304}
305
306impl From<&str> for SecurityGroupId {
307    fn from(value: &str) -> Self {
308        Self(value.to_string())
309    }
310}
311
312#[derive(Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
313#[serde(transparent)]
314pub struct CertificateId(String);
315
316impl CertificateId {
317    pub fn new(value: impl Into<String>) -> Self {
318        Self(value.into())
319    }
320
321    pub fn as_str(&self) -> &str {
322        &self.0
323    }
324}
325
326impl fmt::Debug for CertificateId {
327    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
328        f.debug_tuple("CertificateId").field(&self.0).finish()
329    }
330}
331
332impl fmt::Display for CertificateId {
333    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
334        f.write_str(&self.0)
335    }
336}
337
338impl AsRef<str> for CertificateId {
339    fn as_ref(&self) -> &str {
340        self.as_str()
341    }
342}
343
344impl From<String> for CertificateId {
345    fn from(value: String) -> Self {
346        Self(value)
347    }
348}
349
350impl From<&str> for CertificateId {
351    fn from(value: &str) -> Self {
352        Self(value.to_string())
353    }
354}
355
356#[derive(Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
357#[serde(transparent)]
358pub struct DomainName(String);
359
360impl DomainName {
361    pub fn new(value: impl Into<String>) -> Self {
362        Self(value.into())
363    }
364
365    pub fn as_str(&self) -> &str {
366        &self.0
367    }
368}
369
370impl fmt::Debug for DomainName {
371    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
372        f.debug_tuple("DomainName").field(&self.0).finish()
373    }
374}
375
376impl fmt::Display for DomainName {
377    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
378        f.write_str(&self.0)
379    }
380}
381
382impl AsRef<str> for DomainName {
383    fn as_ref(&self) -> &str {
384        self.as_str()
385    }
386}
387
388impl From<String> for DomainName {
389    fn from(value: String) -> Self {
390        Self(value)
391    }
392}
393
394impl From<&str> for DomainName {
395    fn from(value: &str) -> Self {
396        Self(value.to_string())
397    }
398}