1#[derive(Debug, Clone)]
2pub struct ConfigClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> ConfigClient<T>
7where
8 T: crate::client::Client,
9{
10 pub fn new(client: T, parent_path: &str) -> Self {
11 Self {
12 client,
13 path: format!("{}{}", parent_path, "/config"),
14 }
15 }
16}
17impl<T> ConfigClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Get container configuration."]
22 #[doc = ""]
23 #[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.Audit\"])"]
24 pub async fn get(&self, params: GetParams) -> Result<GetOutput, T::Error> {
25 let path = self.path.to_string();
26 self.client.get(&path, ¶ms).await
27 }
28}
29impl<T> ConfigClient<T>
30where
31 T: crate::client::Client,
32{
33 #[doc = "Set container options."]
34 #[doc = ""]
35 #[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.Config.Disk\", \"VM.Config.CPU\", \"VM.Config.Memory\", \"VM.Config.Network\", \"VM.Config.Options\"], any)"]
36 #[doc = "non-volume mount points in rootfs and mp\\[n\\] are restricted to root@pam"]
37 pub async fn put(&self, params: PutParams) -> Result<(), T::Error> {
38 let path = self.path.to_string();
39 self.client.put(&path, ¶ms).await
40 }
41}
42impl GetOutput {
43 pub fn new(digest: String) -> Self {
44 Self {
45 digest,
46 arch: ::std::default::Default::default(),
47 cmode: ::std::default::Default::default(),
48 console: ::std::default::Default::default(),
49 cores: ::std::default::Default::default(),
50 cpulimit: ::std::default::Default::default(),
51 cpuunits: ::std::default::Default::default(),
52 debug: ::std::default::Default::default(),
53 description: ::std::default::Default::default(),
54 devs: ::std::default::Default::default(),
55 entrypoint: ::std::default::Default::default(),
56 env: ::std::default::Default::default(),
57 features: ::std::default::Default::default(),
58 hookscript: ::std::default::Default::default(),
59 hostname: ::std::default::Default::default(),
60 lock: ::std::default::Default::default(),
61 lxc: ::std::default::Default::default(),
62 memory: ::std::default::Default::default(),
63 mps: ::std::default::Default::default(),
64 nameserver: ::std::default::Default::default(),
65 nets: ::std::default::Default::default(),
66 onboot: ::std::default::Default::default(),
67 ostype: ::std::default::Default::default(),
68 protection: ::std::default::Default::default(),
69 rootfs: ::std::default::Default::default(),
70 searchdomain: ::std::default::Default::default(),
71 startup: ::std::default::Default::default(),
72 swap: ::std::default::Default::default(),
73 tags: ::std::default::Default::default(),
74 template: ::std::default::Default::default(),
75 timezone: ::std::default::Default::default(),
76 tty: ::std::default::Default::default(),
77 unprivileged: ::std::default::Default::default(),
78 unuseds: ::std::default::Default::default(),
79 additional_properties: ::std::default::Default::default(),
80 }
81 }
82}
83#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
84pub struct GetOutput {
85 #[serde(skip_serializing_if = "Option::is_none", default)]
86 #[doc = "OS architecture type."]
87 #[doc = ""]
88 pub arch: Option<Arch>,
89 #[serde(skip_serializing_if = "Option::is_none", default)]
90 #[doc = "Console mode. By default, the console command tries to open a connection to one of the available tty devices. By setting cmode to 'console' it tries to attach to /dev/console instead. If you set cmode to 'shell', it simply invokes a shell inside the container (no login)."]
91 #[doc = ""]
92 pub cmode: Option<Cmode>,
93 #[serde(
94 serialize_with = "crate::types::serialize_bool_optional",
95 deserialize_with = "crate::types::deserialize_bool_optional"
96 )]
97 #[serde(skip_serializing_if = "Option::is_none", default)]
98 #[doc = "Attach a console device (/dev/console) to the container."]
99 #[doc = ""]
100 pub console: Option<bool>,
101 #[serde(skip_serializing_if = "Option::is_none", default)]
102 #[doc = "The number of cores assigned to the container. A container can use all available cores by default."]
103 #[doc = ""]
104 pub cores: Option<CoresInt>,
105 #[serde(skip_serializing_if = "Option::is_none", default)]
106 #[doc = "Limit of CPU usage."]
107 #[doc = ""]
108 #[doc = "NOTE: If the computer has 2 CPUs, it has a total of '2' CPU time. Value '0' indicates no CPU limit."]
109 #[doc = ""]
110 pub cpulimit: Option<CpulimitNum>,
111 #[serde(skip_serializing_if = "Option::is_none", default)]
112 #[doc = "CPU weight for a container, will be clamped to \\\\[1, 10000\\\\] in cgroup v2."]
113 #[doc = ""]
114 #[doc = "CPU weight for a container. Argument is used in the kernel fair scheduler. The larger the number is, the more CPU time this container gets. Number is relative to the weights of all the other running guests."]
115 #[doc = ""]
116 pub cpuunits: Option<CpuunitsInt>,
117 #[serde(
118 serialize_with = "crate::types::serialize_bool_optional",
119 deserialize_with = "crate::types::deserialize_bool_optional"
120 )]
121 #[serde(skip_serializing_if = "Option::is_none", default)]
122 #[doc = "Try to be more verbose. For now this only enables debug log-level on start."]
123 #[doc = ""]
124 pub debug: Option<bool>,
125 #[serde(skip_serializing_if = "Option::is_none", default)]
126 #[doc = "Description for the Container. Shown in the web-interface CT's summary. This is saved as comment inside the configuration file."]
127 #[doc = ""]
128 pub description: Option<DescriptionStr>,
129 #[serde(rename = "dev[n]")]
130 #[serde(
131 serialize_with = "crate::types::serialize_multi::<NumberedDevs, _>",
132 deserialize_with = "crate::types::deserialize_multi::<NumberedDevs, _>"
133 )]
134 #[serde(skip_serializing_if = "::std::collections::HashMap::is_empty", default)]
135 #[serde(flatten)]
136 #[doc = "Device to pass through to the container"]
137 #[doc = ""]
138 pub devs: ::std::collections::HashMap<u32, String>,
139 #[doc = "SHA1 digest of configuration file. This can be used to prevent concurrent modifications."]
140 #[doc = ""]
141 pub digest: String,
142 #[serde(skip_serializing_if = "Option::is_none", default)]
143 #[doc = "Command to run as init, optionally with arguments; may start with an absolute path, relative path, or a binary in $PATH."]
144 #[doc = ""]
145 pub entrypoint: Option<EntrypointStr>,
146 #[serde(skip_serializing_if = "Option::is_none", default)]
147 #[doc = "The container runtime environment as NUL-separated list. Replaces any lxc.environment.runtime entries in the config."]
148 #[doc = ""]
149 pub env: Option<EnvStr>,
150 #[serde(skip_serializing_if = "Option::is_none", default)]
151 #[doc = "Allow containers access to advanced features."]
152 #[doc = ""]
153 pub features: Option<String>,
154 #[serde(skip_serializing_if = "Option::is_none", default)]
155 #[doc = "Script that will be executed during various steps in the containers lifetime."]
156 #[doc = ""]
157 pub hookscript: Option<String>,
158 #[serde(skip_serializing_if = "Option::is_none", default)]
159 #[doc = "Set a host name for the container."]
160 #[doc = ""]
161 pub hostname: Option<HostnameStr>,
162 #[serde(skip_serializing_if = "Option::is_none", default)]
163 #[doc = "Lock/unlock the container."]
164 #[doc = ""]
165 pub lock: Option<Lock>,
166 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
167 #[doc = "Array of lxc low-level configurations (\\\\[\\\\[key1, value1\\\\], \\\\[key2, value2\\\\] ...\\\\])."]
168 #[doc = ""]
169 pub lxc: Vec<Vec<String>>,
170 #[serde(skip_serializing_if = "Option::is_none", default)]
171 #[doc = "Amount of RAM for the container in MB."]
172 #[doc = ""]
173 pub memory: Option<MemoryInt>,
174 #[serde(rename = "mp[n]")]
175 #[serde(
176 serialize_with = "crate::types::serialize_multi::<NumberedMps, _>",
177 deserialize_with = "crate::types::deserialize_multi::<NumberedMps, _>"
178 )]
179 #[serde(skip_serializing_if = "::std::collections::HashMap::is_empty", default)]
180 #[serde(flatten)]
181 #[doc = "Use volume as container mount point. Use the special syntax STORAGE_ID:SIZE_IN_GiB to allocate a new volume."]
182 #[doc = ""]
183 pub mps: ::std::collections::HashMap<u32, String>,
184 #[serde(skip_serializing_if = "Option::is_none", default)]
185 #[doc = "Sets DNS server IP address for a container. Create will automatically use the setting from the host if you neither set searchdomain nor nameserver."]
186 #[doc = ""]
187 pub nameserver: Option<String>,
188 #[serde(rename = "net[n]")]
189 #[serde(
190 serialize_with = "crate::types::serialize_multi::<NumberedNets, _>",
191 deserialize_with = "crate::types::deserialize_multi::<NumberedNets, _>"
192 )]
193 #[serde(skip_serializing_if = "::std::collections::HashMap::is_empty", default)]
194 #[serde(flatten)]
195 #[doc = "Specifies network interfaces for the container."]
196 #[doc = ""]
197 pub nets: ::std::collections::HashMap<u32, String>,
198 #[serde(
199 serialize_with = "crate::types::serialize_bool_optional",
200 deserialize_with = "crate::types::deserialize_bool_optional"
201 )]
202 #[serde(skip_serializing_if = "Option::is_none", default)]
203 #[doc = "Specifies whether a container will be started during system bootup."]
204 #[doc = ""]
205 pub onboot: Option<bool>,
206 #[serde(skip_serializing_if = "Option::is_none", default)]
207 #[doc = "OS type. This is used to setup configuration inside the container, and corresponds to lxc setup scripts in /usr/share/lxc/config/\\\\<ostype\\\\>.common.conf. Value 'unmanaged' can be used to skip and OS specific setup."]
208 #[doc = ""]
209 pub ostype: Option<Ostype>,
210 #[serde(
211 serialize_with = "crate::types::serialize_bool_optional",
212 deserialize_with = "crate::types::deserialize_bool_optional"
213 )]
214 #[serde(skip_serializing_if = "Option::is_none", default)]
215 #[doc = "Sets the protection flag of the container. This will prevent the CT or CT's disk remove/update operation."]
216 #[doc = ""]
217 pub protection: Option<bool>,
218 #[serde(skip_serializing_if = "Option::is_none", default)]
219 #[doc = "Use volume as container root."]
220 #[doc = ""]
221 pub rootfs: Option<String>,
222 #[serde(skip_serializing_if = "Option::is_none", default)]
223 #[doc = "Sets DNS search domains for a container. Create will automatically use the setting from the host if you neither set searchdomain nor nameserver."]
224 #[doc = ""]
225 pub searchdomain: Option<String>,
226 #[serde(skip_serializing_if = "Option::is_none", default)]
227 #[doc = "Startup and shutdown behavior. Order is a non-negative number defining the general startup order. Shutdown in done with reverse ordering. Additionally you can set the 'up' or 'down' delay in seconds, which specifies a delay to wait before the next VM is started or stopped."]
228 #[doc = ""]
229 pub startup: Option<String>,
230 #[serde(skip_serializing_if = "Option::is_none", default)]
231 #[doc = "Amount of SWAP for the container in MB."]
232 #[doc = ""]
233 pub swap: Option<SwapInt>,
234 #[serde(skip_serializing_if = "Option::is_none", default)]
235 #[doc = "Tags of the Container. This is only meta information."]
236 #[doc = ""]
237 pub tags: Option<String>,
238 #[serde(
239 serialize_with = "crate::types::serialize_bool_optional",
240 deserialize_with = "crate::types::deserialize_bool_optional"
241 )]
242 #[serde(skip_serializing_if = "Option::is_none", default)]
243 #[doc = "Enable/disable Template."]
244 #[doc = ""]
245 pub template: Option<bool>,
246 #[serde(skip_serializing_if = "Option::is_none", default)]
247 #[doc = "Time zone to use in the container. If option isn't set, then nothing will be done. Can be set to 'host' to match the host time zone, or an arbitrary time zone option from /usr/share/zoneinfo/zone.tab"]
248 #[doc = ""]
249 pub timezone: Option<String>,
250 #[serde(skip_serializing_if = "Option::is_none", default)]
251 #[doc = "Specify the number of tty available to the container"]
252 #[doc = ""]
253 pub tty: Option<TtyInt>,
254 #[serde(
255 serialize_with = "crate::types::serialize_bool_optional",
256 deserialize_with = "crate::types::deserialize_bool_optional"
257 )]
258 #[serde(skip_serializing_if = "Option::is_none", default)]
259 #[doc = "Makes the container run as unprivileged user. For creation, the default is 1. For restore, the default is the value from the backup. (Should not be modified manually.)"]
260 #[doc = ""]
261 pub unprivileged: Option<bool>,
262 #[serde(rename = "unused[n]")]
263 #[serde(
264 serialize_with = "crate::types::serialize_multi::<NumberedUnuseds, _>",
265 deserialize_with = "crate::types::deserialize_multi::<NumberedUnuseds, _>"
266 )]
267 #[serde(skip_serializing_if = "::std::collections::HashMap::is_empty", default)]
268 #[serde(flatten)]
269 #[doc = "Reference to unused volumes. This is used internally, and should not be modified manually."]
270 #[doc = ""]
271 pub unuseds: ::std::collections::HashMap<u32, String>,
272 #[serde(
273 flatten,
274 deserialize_with = "crate::types::multi::deserialize_additional_data::<'_, GetOutput, _, _>"
275 )]
276 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
277}
278impl crate::types::multi::Test for GetOutput {
279 fn test_fn() -> fn(&str) -> bool {
280 fn the_test(input: &str) -> bool {
281 let array = [
282 <NumberedDevs as crate::types::multi::NumberedItems>::key_matches
283 as fn(&str) -> bool,
284 <NumberedMps as crate::types::multi::NumberedItems>::key_matches
285 as fn(&str) -> bool,
286 <NumberedNets as crate::types::multi::NumberedItems>::key_matches
287 as fn(&str) -> bool,
288 <NumberedUnuseds as crate::types::multi::NumberedItems>::key_matches
289 as fn(&str) -> bool,
290 ];
291 array.iter().any(|f| f(input))
292 }
293 the_test as _
294 }
295}
296#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
297pub struct GetParams {
298 #[serde(
299 serialize_with = "crate::types::serialize_bool_optional",
300 deserialize_with = "crate::types::deserialize_bool_optional"
301 )]
302 #[serde(skip_serializing_if = "Option::is_none", default)]
303 #[doc = "Get current values (instead of pending values)."]
304 #[doc = ""]
305 pub current: Option<bool>,
306 #[serde(skip_serializing_if = "Option::is_none", default)]
307 #[doc = "Fetch config values from given snapshot."]
308 #[doc = ""]
309 pub snapshot: Option<SnapshotStr>,
310 #[serde(
311 flatten,
312 default,
313 skip_serializing_if = "::std::collections::HashMap::is_empty"
314 )]
315 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
316}
317#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
318pub struct PutParams {
319 #[serde(skip_serializing_if = "Option::is_none", default)]
320 #[doc = "OS architecture type."]
321 #[doc = ""]
322 pub arch: Option<Arch>,
323 #[serde(skip_serializing_if = "Option::is_none", default)]
324 #[doc = "Console mode. By default, the console command tries to open a connection to one of the available tty devices. By setting cmode to 'console' it tries to attach to /dev/console instead. If you set cmode to 'shell', it simply invokes a shell inside the container (no login)."]
325 #[doc = ""]
326 pub cmode: Option<Cmode>,
327 #[serde(
328 serialize_with = "crate::types::serialize_bool_optional",
329 deserialize_with = "crate::types::deserialize_bool_optional"
330 )]
331 #[serde(skip_serializing_if = "Option::is_none", default)]
332 #[doc = "Attach a console device (/dev/console) to the container."]
333 #[doc = ""]
334 pub console: Option<bool>,
335 #[serde(skip_serializing_if = "Option::is_none", default)]
336 #[doc = "The number of cores assigned to the container. A container can use all available cores by default."]
337 #[doc = ""]
338 pub cores: Option<CoresInt>,
339 #[serde(skip_serializing_if = "Option::is_none", default)]
340 #[doc = "Limit of CPU usage."]
341 #[doc = ""]
342 #[doc = "NOTE: If the computer has 2 CPUs, it has a total of '2' CPU time. Value '0' indicates no CPU limit."]
343 #[doc = ""]
344 pub cpulimit: Option<CpulimitNum>,
345 #[serde(skip_serializing_if = "Option::is_none", default)]
346 #[doc = "CPU weight for a container, will be clamped to \\\\[1, 10000\\\\] in cgroup v2."]
347 #[doc = ""]
348 #[doc = "CPU weight for a container. Argument is used in the kernel fair scheduler. The larger the number is, the more CPU time this container gets. Number is relative to the weights of all the other running guests."]
349 #[doc = ""]
350 pub cpuunits: Option<CpuunitsInt>,
351 #[serde(
352 serialize_with = "crate::types::serialize_bool_optional",
353 deserialize_with = "crate::types::deserialize_bool_optional"
354 )]
355 #[serde(skip_serializing_if = "Option::is_none", default)]
356 #[doc = "Try to be more verbose. For now this only enables debug log-level on start."]
357 #[doc = ""]
358 pub debug: Option<bool>,
359 #[serde(skip_serializing_if = "Option::is_none", default)]
360 #[doc = "A list of settings you want to delete."]
361 #[doc = ""]
362 pub delete: Option<String>,
363 #[serde(skip_serializing_if = "Option::is_none", default)]
364 #[doc = "Description for the Container. Shown in the web-interface CT's summary. This is saved as comment inside the configuration file."]
365 #[doc = ""]
366 pub description: Option<DescriptionStr>,
367 #[serde(rename = "dev[n]")]
368 #[serde(
369 serialize_with = "crate::types::serialize_multi::<NumberedDevs, _>",
370 deserialize_with = "crate::types::deserialize_multi::<NumberedDevs, _>"
371 )]
372 #[serde(skip_serializing_if = "::std::collections::HashMap::is_empty", default)]
373 #[serde(flatten)]
374 #[doc = "Device to pass through to the container"]
375 #[doc = ""]
376 pub devs: ::std::collections::HashMap<u32, String>,
377 #[serde(skip_serializing_if = "Option::is_none", default)]
378 #[doc = "Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications."]
379 #[doc = ""]
380 pub digest: Option<DigestStr>,
381 #[serde(skip_serializing_if = "Option::is_none", default)]
382 #[doc = "Command to run as init, optionally with arguments; may start with an absolute path, relative path, or a binary in $PATH."]
383 #[doc = ""]
384 pub entrypoint: Option<EntrypointStr>,
385 #[serde(skip_serializing_if = "Option::is_none", default)]
386 #[doc = "The container runtime environment as NUL-separated list. Replaces any lxc.environment.runtime entries in the config."]
387 #[doc = ""]
388 pub env: Option<EnvStr>,
389 #[serde(skip_serializing_if = "Option::is_none", default)]
390 #[doc = "Allow containers access to advanced features."]
391 #[doc = ""]
392 pub features: Option<String>,
393 #[serde(skip_serializing_if = "Option::is_none", default)]
394 #[doc = "Script that will be executed during various steps in the containers lifetime."]
395 #[doc = ""]
396 pub hookscript: Option<String>,
397 #[serde(skip_serializing_if = "Option::is_none", default)]
398 #[doc = "Set a host name for the container."]
399 #[doc = ""]
400 pub hostname: Option<HostnameStr>,
401 #[serde(skip_serializing_if = "Option::is_none", default)]
402 #[doc = "Lock/unlock the container."]
403 #[doc = ""]
404 pub lock: Option<Lock>,
405 #[serde(skip_serializing_if = "Option::is_none", default)]
406 #[doc = "Amount of RAM for the container in MB."]
407 #[doc = ""]
408 pub memory: Option<MemoryInt>,
409 #[serde(rename = "mp[n]")]
410 #[serde(
411 serialize_with = "crate::types::serialize_multi::<NumberedMps, _>",
412 deserialize_with = "crate::types::deserialize_multi::<NumberedMps, _>"
413 )]
414 #[serde(skip_serializing_if = "::std::collections::HashMap::is_empty", default)]
415 #[serde(flatten)]
416 #[doc = "Use volume as container mount point. Use the special syntax STORAGE_ID:SIZE_IN_GiB to allocate a new volume."]
417 #[doc = ""]
418 pub mps: ::std::collections::HashMap<u32, String>,
419 #[serde(skip_serializing_if = "Option::is_none", default)]
420 #[doc = "Sets DNS server IP address for a container. Create will automatically use the setting from the host if you neither set searchdomain nor nameserver."]
421 #[doc = ""]
422 pub nameserver: Option<String>,
423 #[serde(rename = "net[n]")]
424 #[serde(
425 serialize_with = "crate::types::serialize_multi::<NumberedNets, _>",
426 deserialize_with = "crate::types::deserialize_multi::<NumberedNets, _>"
427 )]
428 #[serde(skip_serializing_if = "::std::collections::HashMap::is_empty", default)]
429 #[serde(flatten)]
430 #[doc = "Specifies network interfaces for the container."]
431 #[doc = ""]
432 pub nets: ::std::collections::HashMap<u32, String>,
433 #[serde(
434 serialize_with = "crate::types::serialize_bool_optional",
435 deserialize_with = "crate::types::deserialize_bool_optional"
436 )]
437 #[serde(skip_serializing_if = "Option::is_none", default)]
438 #[doc = "Specifies whether a container will be started during system bootup."]
439 #[doc = ""]
440 pub onboot: Option<bool>,
441 #[serde(skip_serializing_if = "Option::is_none", default)]
442 #[doc = "OS type. This is used to setup configuration inside the container, and corresponds to lxc setup scripts in /usr/share/lxc/config/\\\\<ostype\\\\>.common.conf. Value 'unmanaged' can be used to skip and OS specific setup."]
443 #[doc = ""]
444 pub ostype: Option<Ostype>,
445 #[serde(
446 serialize_with = "crate::types::serialize_bool_optional",
447 deserialize_with = "crate::types::deserialize_bool_optional"
448 )]
449 #[serde(skip_serializing_if = "Option::is_none", default)]
450 #[doc = "Sets the protection flag of the container. This will prevent the CT or CT's disk remove/update operation."]
451 #[doc = ""]
452 pub protection: Option<bool>,
453 #[serde(skip_serializing_if = "Option::is_none", default)]
454 #[doc = "Revert a pending change."]
455 #[doc = ""]
456 pub revert: Option<String>,
457 #[serde(skip_serializing_if = "Option::is_none", default)]
458 #[doc = "Use volume as container root."]
459 #[doc = ""]
460 pub rootfs: Option<String>,
461 #[serde(skip_serializing_if = "Option::is_none", default)]
462 #[doc = "Sets DNS search domains for a container. Create will automatically use the setting from the host if you neither set searchdomain nor nameserver."]
463 #[doc = ""]
464 pub searchdomain: Option<String>,
465 #[serde(skip_serializing_if = "Option::is_none", default)]
466 #[doc = "Startup and shutdown behavior. Order is a non-negative number defining the general startup order. Shutdown in done with reverse ordering. Additionally you can set the 'up' or 'down' delay in seconds, which specifies a delay to wait before the next VM is started or stopped."]
467 #[doc = ""]
468 pub startup: Option<String>,
469 #[serde(skip_serializing_if = "Option::is_none", default)]
470 #[doc = "Amount of SWAP for the container in MB."]
471 #[doc = ""]
472 pub swap: Option<SwapInt>,
473 #[serde(skip_serializing_if = "Option::is_none", default)]
474 #[doc = "Tags of the Container. This is only meta information."]
475 #[doc = ""]
476 pub tags: Option<String>,
477 #[serde(
478 serialize_with = "crate::types::serialize_bool_optional",
479 deserialize_with = "crate::types::deserialize_bool_optional"
480 )]
481 #[serde(skip_serializing_if = "Option::is_none", default)]
482 #[doc = "Enable/disable Template."]
483 #[doc = ""]
484 pub template: Option<bool>,
485 #[serde(skip_serializing_if = "Option::is_none", default)]
486 #[doc = "Time zone to use in the container. If option isn't set, then nothing will be done. Can be set to 'host' to match the host time zone, or an arbitrary time zone option from /usr/share/zoneinfo/zone.tab"]
487 #[doc = ""]
488 pub timezone: Option<String>,
489 #[serde(skip_serializing_if = "Option::is_none", default)]
490 #[doc = "Specify the number of tty available to the container"]
491 #[doc = ""]
492 pub tty: Option<TtyInt>,
493 #[serde(
494 serialize_with = "crate::types::serialize_bool_optional",
495 deserialize_with = "crate::types::deserialize_bool_optional"
496 )]
497 #[serde(skip_serializing_if = "Option::is_none", default)]
498 #[doc = "Makes the container run as unprivileged user. For creation, the default is 1. For restore, the default is the value from the backup. (Should not be modified manually.)"]
499 #[doc = ""]
500 pub unprivileged: Option<bool>,
501 #[serde(rename = "unused[n]")]
502 #[serde(
503 serialize_with = "crate::types::serialize_multi::<NumberedUnuseds, _>",
504 deserialize_with = "crate::types::deserialize_multi::<NumberedUnuseds, _>"
505 )]
506 #[serde(skip_serializing_if = "::std::collections::HashMap::is_empty", default)]
507 #[serde(flatten)]
508 #[doc = "Reference to unused volumes. This is used internally, and should not be modified manually."]
509 #[doc = ""]
510 pub unuseds: ::std::collections::HashMap<u32, String>,
511 #[serde(
512 flatten,
513 deserialize_with = "crate::types::multi::deserialize_additional_data::<'_, PutParams, _, _>"
514 )]
515 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
516}
517impl crate::types::multi::Test for PutParams {
518 fn test_fn() -> fn(&str) -> bool {
519 fn the_test(input: &str) -> bool {
520 let array = [
521 <NumberedDevs as crate::types::multi::NumberedItems>::key_matches
522 as fn(&str) -> bool,
523 <NumberedMps as crate::types::multi::NumberedItems>::key_matches
524 as fn(&str) -> bool,
525 <NumberedNets as crate::types::multi::NumberedItems>::key_matches
526 as fn(&str) -> bool,
527 <NumberedUnuseds as crate::types::multi::NumberedItems>::key_matches
528 as fn(&str) -> bool,
529 ];
530 array.iter().any(|f| f(input))
531 }
532 the_test as _
533 }
534}
535#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq, Default)]
536#[doc = "OS architecture type."]
537#[doc = ""]
538pub enum Arch {
539 #[serde(rename = "amd64")]
540 #[default]
541 Amd64,
542 #[serde(rename = "arm64")]
543 Arm64,
544 #[serde(rename = "armhf")]
545 Armhf,
546 #[serde(rename = "i386")]
547 I386,
548 #[serde(rename = "riscv32")]
549 Riscv32,
550 #[serde(rename = "riscv64")]
551 Riscv64,
552}
553impl TryFrom<&str> for Arch {
554 type Error = String;
555 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
556 match value {
557 "amd64" => Ok(Self::Amd64),
558 "arm64" => Ok(Self::Arm64),
559 "armhf" => Ok(Self::Armhf),
560 "i386" => Ok(Self::I386),
561 "riscv32" => Ok(Self::Riscv32),
562 "riscv64" => Ok(Self::Riscv64),
563 v => Err(format!("Unknown variant {v}")),
564 }
565 }
566}
567#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq, Default)]
568#[doc = "Console mode. By default, the console command tries to open a connection to one of the available tty devices. By setting cmode to 'console' it tries to attach to /dev/console instead. If you set cmode to 'shell', it simply invokes a shell inside the container (no login)."]
569#[doc = ""]
570pub enum Cmode {
571 #[serde(rename = "console")]
572 Console,
573 #[serde(rename = "shell")]
574 Shell,
575 #[serde(rename = "tty")]
576 #[default]
577 Tty,
578}
579impl TryFrom<&str> for Cmode {
580 type Error = String;
581 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
582 match value {
583 "console" => Ok(Self::Console),
584 "shell" => Ok(Self::Shell),
585 "tty" => Ok(Self::Tty),
586 v => Err(format!("Unknown variant {v}")),
587 }
588 }
589}
590#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
591#[doc = "Lock/unlock the container."]
592#[doc = ""]
593pub enum Lock {
594 #[serde(rename = "backup")]
595 Backup,
596 #[serde(rename = "create")]
597 Create,
598 #[serde(rename = "destroyed")]
599 Destroyed,
600 #[serde(rename = "disk")]
601 Disk,
602 #[serde(rename = "fstrim")]
603 Fstrim,
604 #[serde(rename = "migrate")]
605 Migrate,
606 #[serde(rename = "mounted")]
607 Mounted,
608 #[serde(rename = "rollback")]
609 Rollback,
610 #[serde(rename = "snapshot")]
611 Snapshot,
612 #[serde(rename = "snapshot-delete")]
613 SnapshotDelete,
614}
615impl TryFrom<&str> for Lock {
616 type Error = String;
617 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
618 match value {
619 "backup" => Ok(Self::Backup),
620 "create" => Ok(Self::Create),
621 "destroyed" => Ok(Self::Destroyed),
622 "disk" => Ok(Self::Disk),
623 "fstrim" => Ok(Self::Fstrim),
624 "migrate" => Ok(Self::Migrate),
625 "mounted" => Ok(Self::Mounted),
626 "rollback" => Ok(Self::Rollback),
627 "snapshot" => Ok(Self::Snapshot),
628 "snapshot-delete" => Ok(Self::SnapshotDelete),
629 v => Err(format!("Unknown variant {v}")),
630 }
631 }
632}
633#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
634#[doc = "OS type. This is used to setup configuration inside the container, and corresponds to lxc setup scripts in /usr/share/lxc/config/\\<ostype\\>.common.conf. Value 'unmanaged' can be used to skip and OS specific setup."]
635#[doc = ""]
636pub enum Ostype {
637 #[serde(rename = "alpine")]
638 Alpine,
639 #[serde(rename = "archlinux")]
640 Archlinux,
641 #[serde(rename = "centos")]
642 Centos,
643 #[serde(rename = "debian")]
644 Debian,
645 #[serde(rename = "devuan")]
646 Devuan,
647 #[serde(rename = "fedora")]
648 Fedora,
649 #[serde(rename = "gentoo")]
650 Gentoo,
651 #[serde(rename = "nixos")]
652 Nixos,
653 #[serde(rename = "opensuse")]
654 Opensuse,
655 #[serde(rename = "ubuntu")]
656 Ubuntu,
657 #[serde(rename = "unmanaged")]
658 Unmanaged,
659}
660impl TryFrom<&str> for Ostype {
661 type Error = String;
662 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
663 match value {
664 "alpine" => Ok(Self::Alpine),
665 "archlinux" => Ok(Self::Archlinux),
666 "centos" => Ok(Self::Centos),
667 "debian" => Ok(Self::Debian),
668 "devuan" => Ok(Self::Devuan),
669 "fedora" => Ok(Self::Fedora),
670 "gentoo" => Ok(Self::Gentoo),
671 "nixos" => Ok(Self::Nixos),
672 "opensuse" => Ok(Self::Opensuse),
673 "ubuntu" => Ok(Self::Ubuntu),
674 "unmanaged" => Ok(Self::Unmanaged),
675 v => Err(format!("Unknown variant {v}")),
676 }
677 }
678}
679#[derive(Default)]
680struct NumberedDevs;
681impl crate::types::multi::NumberedItems for NumberedDevs {
682 type Item = String;
683 const PREFIX: &'static str = "dev";
684}
685#[derive(Default)]
686struct NumberedMps;
687impl crate::types::multi::NumberedItems for NumberedMps {
688 type Item = String;
689 const PREFIX: &'static str = "mp";
690}
691#[derive(Default)]
692struct NumberedNets;
693impl crate::types::multi::NumberedItems for NumberedNets {
694 type Item = String;
695 const PREFIX: &'static str = "net";
696}
697#[derive(Default)]
698struct NumberedUnuseds;
699impl crate::types::multi::NumberedItems for NumberedUnuseds {
700 type Item = String;
701 const PREFIX: &'static str = "unused";
702}
703#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
704pub struct CoresInt(i128);
705impl crate::types::bounded_integer::BoundedInteger for CoresInt {
706 const MIN: Option<i128> = Some(1i128);
707 const MAX: Option<i128> = Some(8192i128);
708 const DEFAULT: Option<i128> = None::<i128>;
709 const TYPE_DESCRIPTION: &'static str = "an integer between 1 and 8192";
710 fn get(&self) -> i128 {
711 self.0
712 }
713 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
714 Self::validate(value)?;
715 Ok(Self(value))
716 }
717}
718impl std::convert::TryFrom<i128> for CoresInt {
719 type Error = crate::types::bounded_integer::BoundedIntegerError;
720 fn try_from(value: i128) -> Result<Self, Self::Error> {
721 crate::types::bounded_integer::BoundedInteger::new(value)
722 }
723}
724impl ::serde::Serialize for CoresInt {
725 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
726 where
727 S: ::serde::Serializer,
728 {
729 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
730 }
731}
732impl<'de> ::serde::Deserialize<'de> for CoresInt {
733 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
734 where
735 D: ::serde::Deserializer<'de>,
736 {
737 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
738 }
739}
740#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
741pub struct CpuunitsInt(i128);
742impl crate::types::bounded_integer::BoundedInteger for CpuunitsInt {
743 const MIN: Option<i128> = Some(0i128);
744 const MAX: Option<i128> = Some(500000i128);
745 const DEFAULT: Option<i128> = None::<i128>;
746 const TYPE_DESCRIPTION: &'static str = "an integer between 0 and 500000";
747 fn get(&self) -> i128 {
748 self.0
749 }
750 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
751 Self::validate(value)?;
752 Ok(Self(value))
753 }
754}
755impl std::convert::TryFrom<i128> for CpuunitsInt {
756 type Error = crate::types::bounded_integer::BoundedIntegerError;
757 fn try_from(value: i128) -> Result<Self, Self::Error> {
758 crate::types::bounded_integer::BoundedInteger::new(value)
759 }
760}
761impl ::serde::Serialize for CpuunitsInt {
762 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
763 where
764 S: ::serde::Serializer,
765 {
766 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
767 }
768}
769impl<'de> ::serde::Deserialize<'de> for CpuunitsInt {
770 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
771 where
772 D: ::serde::Deserializer<'de>,
773 {
774 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
775 }
776}
777#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
778pub struct MemoryInt(i128);
779impl crate::types::bounded_integer::BoundedInteger for MemoryInt {
780 const MIN: Option<i128> = Some(16i128);
781 const MAX: Option<i128> = None::<i128>;
782 const DEFAULT: Option<i128> = Some(512i128);
783 const TYPE_DESCRIPTION: &'static str = "an integer greater than or equal to 16";
784 fn get(&self) -> i128 {
785 self.0
786 }
787 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
788 Self::validate(value)?;
789 Ok(Self(value))
790 }
791}
792impl std::convert::TryFrom<i128> for MemoryInt {
793 type Error = crate::types::bounded_integer::BoundedIntegerError;
794 fn try_from(value: i128) -> Result<Self, Self::Error> {
795 crate::types::bounded_integer::BoundedInteger::new(value)
796 }
797}
798impl ::serde::Serialize for MemoryInt {
799 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
800 where
801 S: ::serde::Serializer,
802 {
803 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
804 }
805}
806impl<'de> ::serde::Deserialize<'de> for MemoryInt {
807 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
808 where
809 D: ::serde::Deserializer<'de>,
810 {
811 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
812 }
813}
814#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
815pub struct SwapInt(i128);
816impl crate::types::bounded_integer::BoundedInteger for SwapInt {
817 const MIN: Option<i128> = Some(0i128);
818 const MAX: Option<i128> = None::<i128>;
819 const DEFAULT: Option<i128> = Some(512i128);
820 const TYPE_DESCRIPTION: &'static str = "an integer greater than or equal to 0";
821 fn get(&self) -> i128 {
822 self.0
823 }
824 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
825 Self::validate(value)?;
826 Ok(Self(value))
827 }
828}
829impl std::convert::TryFrom<i128> for SwapInt {
830 type Error = crate::types::bounded_integer::BoundedIntegerError;
831 fn try_from(value: i128) -> Result<Self, Self::Error> {
832 crate::types::bounded_integer::BoundedInteger::new(value)
833 }
834}
835impl ::serde::Serialize for SwapInt {
836 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
837 where
838 S: ::serde::Serializer,
839 {
840 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
841 }
842}
843impl<'de> ::serde::Deserialize<'de> for SwapInt {
844 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
845 where
846 D: ::serde::Deserializer<'de>,
847 {
848 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
849 }
850}
851#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
852pub struct TtyInt(i128);
853impl crate::types::bounded_integer::BoundedInteger for TtyInt {
854 const MIN: Option<i128> = Some(0i128);
855 const MAX: Option<i128> = Some(6i128);
856 const DEFAULT: Option<i128> = Some(2i128);
857 const TYPE_DESCRIPTION: &'static str = "an integer between 0 and 6";
858 fn get(&self) -> i128 {
859 self.0
860 }
861 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
862 Self::validate(value)?;
863 Ok(Self(value))
864 }
865}
866impl std::convert::TryFrom<i128> for TtyInt {
867 type Error = crate::types::bounded_integer::BoundedIntegerError;
868 fn try_from(value: i128) -> Result<Self, Self::Error> {
869 crate::types::bounded_integer::BoundedInteger::new(value)
870 }
871}
872impl ::serde::Serialize for TtyInt {
873 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
874 where
875 S: ::serde::Serializer,
876 {
877 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
878 }
879}
880impl<'de> ::serde::Deserialize<'de> for TtyInt {
881 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
882 where
883 D: ::serde::Deserializer<'de>,
884 {
885 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
886 }
887}
888#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
889pub struct CpulimitNum(f64);
890impl crate::types::bounded_number::BoundedNumber for CpulimitNum {
891 const MIN: Option<f64> = Some(0f64);
892 const MAX: Option<f64> = Some(8192f64);
893 const DEFAULT: Option<f64> = Some(0f64);
894 const TYPE_DESCRIPTION: &'static str = "an number between 0 and 8192";
895 fn get(&self) -> f64 {
896 self.0
897 }
898 fn new(value: f64) -> Result<Self, crate::types::bounded_number::BoundedNumberError> {
899 Self::validate(value)?;
900 Ok(Self(value))
901 }
902}
903impl std::convert::TryFrom<f64> for CpulimitNum {
904 type Error = crate::types::bounded_number::BoundedNumberError;
905 fn try_from(value: f64) -> Result<Self, Self::Error> {
906 crate::types::bounded_number::BoundedNumber::new(value)
907 }
908}
909impl std::convert::TryFrom<f32> for CpulimitNum {
910 type Error = crate::types::bounded_number::BoundedNumberError;
911 fn try_from(value: f32) -> Result<Self, Self::Error> {
912 crate::types::bounded_number::BoundedNumber::new(value as f64)
913 }
914}
915impl std::convert::TryFrom<i32> for CpulimitNum {
916 type Error = crate::types::bounded_number::BoundedNumberError;
917 fn try_from(value: i32) -> Result<Self, Self::Error> {
918 crate::types::bounded_number::BoundedNumber::new(value as f64)
919 }
920}
921impl std::convert::TryFrom<i64> for CpulimitNum {
922 type Error = crate::types::bounded_number::BoundedNumberError;
923 fn try_from(value: i64) -> Result<Self, Self::Error> {
924 crate::types::bounded_number::BoundedNumber::new(value as f64)
925 }
926}
927impl ::serde::Serialize for CpulimitNum {
928 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
929 where
930 S: ::serde::Serializer,
931 {
932 crate::types::bounded_number::serialize_bounded_number(self, serializer)
933 }
934}
935impl<'de> ::serde::Deserialize<'de> for CpulimitNum {
936 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
937 where
938 D: ::serde::Deserializer<'de>,
939 {
940 crate::types::bounded_number::deserialize_bounded_number(deserializer)
941 }
942}
943#[derive(Debug, Clone, PartialEq, PartialOrd)]
944pub struct DescriptionStr {
945 value: String,
946}
947impl crate::types::bounded_string::BoundedString for DescriptionStr {
948 const MIN_LENGTH: Option<usize> = None::<usize>;
949 const MAX_LENGTH: Option<usize> = Some(8192usize);
950 const DEFAULT: Option<&'static str> = None::<&'static str>;
951 const PATTERN: Option<&'static str> = None::<&'static str>;
952 const TYPE_DESCRIPTION: &'static str = "a string with length at most 8192";
953 fn get_value(&self) -> &str {
954 &self.value
955 }
956 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
957 Self::validate(&value)?;
958 Ok(Self { value })
959 }
960}
961impl std::convert::TryFrom<String> for DescriptionStr {
962 type Error = crate::types::bounded_string::BoundedStringError;
963 fn try_from(value: String) -> Result<Self, Self::Error> {
964 crate::types::bounded_string::BoundedString::new(value)
965 }
966}
967impl ::serde::Serialize for DescriptionStr {
968 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
969 where
970 S: ::serde::Serializer,
971 {
972 crate::types::bounded_string::serialize_bounded_string(self, serializer)
973 }
974}
975impl<'de> ::serde::Deserialize<'de> for DescriptionStr {
976 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
977 where
978 D: ::serde::Deserializer<'de>,
979 {
980 crate::types::bounded_string::deserialize_bounded_string(deserializer)
981 }
982}
983#[derive(Debug, Clone, PartialEq, PartialOrd)]
984pub struct DigestStr {
985 value: String,
986}
987impl crate::types::bounded_string::BoundedString for DigestStr {
988 const MIN_LENGTH: Option<usize> = None::<usize>;
989 const MAX_LENGTH: Option<usize> = Some(40usize);
990 const DEFAULT: Option<&'static str> = None::<&'static str>;
991 const PATTERN: Option<&'static str> = None::<&'static str>;
992 const TYPE_DESCRIPTION: &'static str = "a string with length at most 40";
993 fn get_value(&self) -> &str {
994 &self.value
995 }
996 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
997 Self::validate(&value)?;
998 Ok(Self { value })
999 }
1000}
1001impl std::convert::TryFrom<String> for DigestStr {
1002 type Error = crate::types::bounded_string::BoundedStringError;
1003 fn try_from(value: String) -> Result<Self, Self::Error> {
1004 crate::types::bounded_string::BoundedString::new(value)
1005 }
1006}
1007impl ::serde::Serialize for DigestStr {
1008 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1009 where
1010 S: ::serde::Serializer,
1011 {
1012 crate::types::bounded_string::serialize_bounded_string(self, serializer)
1013 }
1014}
1015impl<'de> ::serde::Deserialize<'de> for DigestStr {
1016 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1017 where
1018 D: ::serde::Deserializer<'de>,
1019 {
1020 crate::types::bounded_string::deserialize_bounded_string(deserializer)
1021 }
1022}
1023#[derive(Debug, Clone, PartialEq, PartialOrd)]
1024pub struct EntrypointStr {
1025 value: String,
1026}
1027impl crate::types::bounded_string::BoundedString for EntrypointStr {
1028 const MIN_LENGTH: Option<usize> = None::<usize>;
1029 const MAX_LENGTH: Option<usize> = None::<usize>;
1030 const DEFAULT: Option<&'static str> = Some("/sbin/init");
1031 const PATTERN: Option<&'static str> = Some("(?^:[^\\x00-\\x08\\x10-\\x1F\\x7F]+)");
1032 const TYPE_DESCRIPTION: &'static str =
1033 "a string with pattern r\"(?^:[^\\x00-\\x08\\x10-\\x1F\\x7F]+)\" and no length constraints";
1034 fn get_value(&self) -> &str {
1035 &self.value
1036 }
1037 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
1038 Self::validate(&value)?;
1039 Ok(Self { value })
1040 }
1041}
1042impl std::convert::TryFrom<String> for EntrypointStr {
1043 type Error = crate::types::bounded_string::BoundedStringError;
1044 fn try_from(value: String) -> Result<Self, Self::Error> {
1045 crate::types::bounded_string::BoundedString::new(value)
1046 }
1047}
1048impl ::serde::Serialize for EntrypointStr {
1049 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1050 where
1051 S: ::serde::Serializer,
1052 {
1053 crate::types::bounded_string::serialize_bounded_string(self, serializer)
1054 }
1055}
1056impl<'de> ::serde::Deserialize<'de> for EntrypointStr {
1057 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1058 where
1059 D: ::serde::Deserializer<'de>,
1060 {
1061 crate::types::bounded_string::deserialize_bounded_string(deserializer)
1062 }
1063}
1064#[derive(Debug, Clone, PartialEq, PartialOrd)]
1065pub struct EnvStr {
1066 value: String,
1067}
1068impl crate::types::bounded_string::BoundedString for EnvStr {
1069 const MIN_LENGTH: Option<usize> = None::<usize>;
1070 const MAX_LENGTH: Option<usize> = None::<usize>;
1071 const DEFAULT: Option<&'static str> = None::<&'static str>;
1072 const PATTERN: Option<&'static str> = Some(
1073 "(?^:(?:\\w+=[^\\x00-\\x08\\x10-\\x1F\\x7F]*)(?:\\0\\w+=[^\\x00-\\x08\\x10-\\x1F\\x7F]*)*)",
1074 );
1075 const TYPE_DESCRIPTION: &'static str = "a string with pattern r\"(?^:(?:\\w+=[^\\x00-\\x08\\x10-\\x1F\\x7F]*)(?:\\0\\w+=[^\\x00-\\x08\\x10-\\x1F\\x7F]*)*)\" and no length constraints";
1076 fn get_value(&self) -> &str {
1077 &self.value
1078 }
1079 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
1080 Self::validate(&value)?;
1081 Ok(Self { value })
1082 }
1083}
1084impl std::convert::TryFrom<String> for EnvStr {
1085 type Error = crate::types::bounded_string::BoundedStringError;
1086 fn try_from(value: String) -> Result<Self, Self::Error> {
1087 crate::types::bounded_string::BoundedString::new(value)
1088 }
1089}
1090impl ::serde::Serialize for EnvStr {
1091 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1092 where
1093 S: ::serde::Serializer,
1094 {
1095 crate::types::bounded_string::serialize_bounded_string(self, serializer)
1096 }
1097}
1098impl<'de> ::serde::Deserialize<'de> for EnvStr {
1099 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1100 where
1101 D: ::serde::Deserializer<'de>,
1102 {
1103 crate::types::bounded_string::deserialize_bounded_string(deserializer)
1104 }
1105}
1106#[derive(Debug, Clone, PartialEq, PartialOrd)]
1107pub struct HostnameStr {
1108 value: String,
1109}
1110impl crate::types::bounded_string::BoundedString for HostnameStr {
1111 const MIN_LENGTH: Option<usize> = None::<usize>;
1112 const MAX_LENGTH: Option<usize> = Some(255usize);
1113 const DEFAULT: Option<&'static str> = None::<&'static str>;
1114 const PATTERN: Option<&'static str> = None::<&'static str>;
1115 const TYPE_DESCRIPTION: &'static str = "a string with length at most 255";
1116 fn get_value(&self) -> &str {
1117 &self.value
1118 }
1119 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
1120 Self::validate(&value)?;
1121 Ok(Self { value })
1122 }
1123}
1124impl std::convert::TryFrom<String> for HostnameStr {
1125 type Error = crate::types::bounded_string::BoundedStringError;
1126 fn try_from(value: String) -> Result<Self, Self::Error> {
1127 crate::types::bounded_string::BoundedString::new(value)
1128 }
1129}
1130impl ::serde::Serialize for HostnameStr {
1131 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1132 where
1133 S: ::serde::Serializer,
1134 {
1135 crate::types::bounded_string::serialize_bounded_string(self, serializer)
1136 }
1137}
1138impl<'de> ::serde::Deserialize<'de> for HostnameStr {
1139 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1140 where
1141 D: ::serde::Deserializer<'de>,
1142 {
1143 crate::types::bounded_string::deserialize_bounded_string(deserializer)
1144 }
1145}
1146#[derive(Debug, Clone, PartialEq, PartialOrd)]
1147pub struct SnapshotStr {
1148 value: String,
1149}
1150impl crate::types::bounded_string::BoundedString for SnapshotStr {
1151 const MIN_LENGTH: Option<usize> = None::<usize>;
1152 const MAX_LENGTH: Option<usize> = Some(40usize);
1153 const DEFAULT: Option<&'static str> = None::<&'static str>;
1154 const PATTERN: Option<&'static str> = None::<&'static str>;
1155 const TYPE_DESCRIPTION: &'static str = "a string with length at most 40";
1156 fn get_value(&self) -> &str {
1157 &self.value
1158 }
1159 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
1160 Self::validate(&value)?;
1161 Ok(Self { value })
1162 }
1163}
1164impl std::convert::TryFrom<String> for SnapshotStr {
1165 type Error = crate::types::bounded_string::BoundedStringError;
1166 fn try_from(value: String) -> Result<Self, Self::Error> {
1167 crate::types::bounded_string::BoundedString::new(value)
1168 }
1169}
1170impl ::serde::Serialize for SnapshotStr {
1171 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1172 where
1173 S: ::serde::Serializer,
1174 {
1175 crate::types::bounded_string::serialize_bounded_string(self, serializer)
1176 }
1177}
1178impl<'de> ::serde::Deserialize<'de> for SnapshotStr {
1179 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1180 where
1181 D: ::serde::Deserializer<'de>,
1182 {
1183 crate::types::bounded_string::deserialize_bounded_string(deserializer)
1184 }
1185}