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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// The *HostActiveDirectoryAuthentication* managed object
/// indicates domain membership status and provides methods
/// for adding a host to and removing a host from a domain.
#[derive(Clone)]
pub struct HostActiveDirectoryAuthentication {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl HostActiveDirectoryAuthentication {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
/// Deprecated as of vSphere API 8.0U3, and there is no replacement for it.
///
/// Disables console authentication using a local smart card and reader.
///
/// ***Required privileges:*** Host.Config.AuthenticationStore
///
/// ## Errors:
///
/// ***ActiveDirectoryFault***: if the active directory client could not
/// be reconfigured.
///
/// ***HostConfigFault***: if the host configuration prevents smart card
/// authentication from being disabled.
pub async fn disable_smart_card_authentication(&self) -> Result<()> {
self.client.invoke_void("", "HostActiveDirectoryAuthentication", &self.mo_id, "DisableSmartCardAuthentication", None).await
}
/// Deprecated as of vSphere API 8.0U3, and there is no replacement for it.
///
/// Enables console authentication using a local smart card and reader.
///
/// To take effect this feature requires an active domain membership to a
/// domain with users configured to authenticate using smart cards.
///
/// ***Required privileges:*** Host.Config.AuthenticationStore
///
/// ## Errors:
///
/// ***ActiveDirectoryFault***: if the active directory client could not
/// be reconfigured.
///
/// ***HostConfigFault***: if the host configuration prevents smart card
/// authentication from being enabled.
pub async fn enable_smart_card_authentication(&self) -> Result<()> {
self.client.invoke_void("", "HostActiveDirectoryAuthentication", &self.mo_id, "EnableSmartCardAuthentication", None).await
}
/// Import the CAM server's certificate to the local store of vmwauth.
///
/// The certificate should have already been uploaded to ESXi file system.
///
/// ***Required privileges:*** Host.Config.AuthenticationStore
///
/// ## Parameters:
///
/// ### cert_path
/// full path of the certificate on ESXi
///
/// ### cam_server
/// IP of server providing the CAM service.
///
/// ## Returns:
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***FileNotFound***: if the certificate file does not exist
///
/// ***InvalidCAMServer***: if camServer is not a valid IP address
///
/// ***ActiveDirectoryFault***: for any problem that is not handled with a more specific fault.
pub async fn import_certificate_for_cam_task(&self, cert_path: &str, cam_server: &str) -> Result<crate::types::structs::ManagedObjectReference> {
let input = ImportCertificateForCamRequestType {cert_path, cam_server, };
let bytes = self.client.invoke("", "HostActiveDirectoryAuthentication", &self.mo_id, "ImportCertificateForCAM_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Deprecated as of vSphere API 8.0U3, and there is no replacement for it.
///
/// Install a trust anchor certificate for smart card authentication.
///
/// ***Required privileges:*** Host.Config.AuthenticationStore
///
/// ## Parameters:
///
/// ### cert
/// SSL certificate in PEM format
///
/// ## Errors:
///
/// ***HostConfigFault***: if the host configuration prevents the
/// certificate from being installed.
pub async fn install_smart_card_trust_anchor(&self, cert: &str) -> Result<()> {
let input = InstallSmartCardTrustAnchorRequestType {cert, };
self.client.invoke_void("", "HostActiveDirectoryAuthentication", &self.mo_id, "InstallSmartCardTrustAnchor", Some(&input)).await
}
/// Adds the host to an Active Directory domain.
///
/// If the *HostAuthenticationStoreInfo*.*HostAuthenticationStoreInfo.enabled*
/// property is <code>True</code> (accessed through the <code>info</code> property),
/// the host has joined a domain.
/// The vSphere API will throw the <code>InvalidState</code> fault if you try
/// to add a host to a domain when the host has already joined a domain.
///
/// ***Required privileges:*** Host.Config.AuthenticationStore
///
/// ## Parameters:
///
/// ### domain_name
/// Name of the domain to be joined.
///
/// ### user_name
/// Name for an Active Directory account
/// that has the authority to add hosts to the domain.
///
/// ### password
/// Password for the <code>userName</code> account.
///
/// ## Returns:
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidState***: if the host has already joined a domain.
///
/// ***BlockedByFirewall***: if ports needed by the join operation are
/// blocked by the firewall.
///
/// ***HostConfigFault***: if the host configuration prevents the join operation
/// from succeeding.
///
/// ***InvalidLogin***: if <code>userName</code> and <code>password</code>
/// are not valid user credentials.
///
/// ***DomainNotFound***: if the domain controller for <code>domainName</code>
/// cannot be reached.
///
/// ***NoPermissionOnAD***: if <code>userName</code> has no right to add hosts to the domain.
///
/// ***InvalidHostName***: if the domain part of the host's FQDN doesn't match
/// the domain being joined.
///
/// ***ClockSkew***: if the clocks of the host and the domain controller
/// differ by more than the allowed amount of time.
///
/// ***ActiveDirectoryFault***: for any problem that is not handled with a more specific fault.
///
/// ***TaskInProgress***: if the *HostActiveDirectoryAuthentication* object is busy.
pub async fn join_domain_task(&self, domain_name: &str, user_name: &str, password: &str) -> Result<crate::types::structs::ManagedObjectReference> {
let input = JoinDomainRequestType {domain_name, user_name, password, };
let bytes = self.client.invoke("", "HostActiveDirectoryAuthentication", &self.mo_id, "JoinDomain_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Adds the host to an Active Directory domain through CAM service.
///
/// If the *HostAuthenticationStoreInfo*.*HostAuthenticationStoreInfo.enabled*
/// property is <code>True</code> (accessed through the <code>info</code> property),
/// the host has joined a domain.
/// The vSphere API will throw the <code>InvalidState</code> fault if you try
/// to add a host to a domain when the host has already joined a domain.
///
/// ***Required privileges:*** Host.Config.AuthenticationStore
///
/// ## Parameters:
///
/// ### domain_name
/// Name of the domain to be joined.
///
/// ### cam_server
/// Name of server providing the CAM service.
///
/// ## Returns:
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidState***: if the host has already joined a domain.
///
/// ***BlockedByFirewall***: if ports needed by the join operation are
/// blocked by the firewall.
///
/// ***HostConfigFault***: if the host configuration prevents the join operation
/// from succeeding.
///
/// ***DomainNotFound***: if the domain controller for <code>domainName</code>
/// cannot be reached.
///
/// ***InvalidHostName***: if the domain part of the host's FQDN doesn't match
/// the domain being joined.
///
/// ***ClockSkew***: if the clocks of the host and the domain controller
/// differ by more than the allowed amount of time.
///
/// ***InvalidCAMServer***: if camServer is not a valid IP address, or
/// if camServer is not accessible.
///
/// ***InvalidCAMCertificate***: if the certificate of the given CAM server
/// cannot be verified.
///
/// ***CAMServerRefusedConnection***: if the specified CAM server is not
/// reachable, or
/// if the server denied access.
///
/// ***ActiveDirectoryFault***: for any problem that is not handled with a more specific fault.
///
/// ***TaskInProgress***: if the *HostActiveDirectoryAuthentication* object is busy.
pub async fn join_domain_with_cam_task(&self, domain_name: &str, cam_server: &str) -> Result<crate::types::structs::ManagedObjectReference> {
let input = JoinDomainWithCamRequestType {domain_name, cam_server, };
let bytes = self.client.invoke("", "HostActiveDirectoryAuthentication", &self.mo_id, "JoinDomainWithCAM_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Removes the host from the Active Directory domain to which it belongs.
///
/// ***Required privileges:*** Host.Config.AuthenticationStore
///
/// ## Parameters:
///
/// ### force
/// If <code>True</code>, any existing permissions on managed entities for
/// Active Directory users will be deleted. If <code>False</code> and such
/// permissions exist, the operation will fail.
///
/// ## Returns:
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidState***: if the host is not in a domain or there are active
/// permissions for Active Directory users.
///
/// ***NonADUserRequired***: only non Active Directory users can initiate
/// the leave domain operation.
///
/// ***AuthMinimumAdminPermission***: if this change would leave the system with
/// no Administrator permission on the root node.
///
/// ***ActiveDirectoryFault***: for any problem that is not handled with a specific fault.
///
/// ***TaskInProgress***: if the ActiveDirectoryAuthentication object is busy.
pub async fn leave_current_domain_task(&self, force: bool) -> Result<crate::types::structs::ManagedObjectReference> {
let input = LeaveCurrentDomainRequestType {force, };
let bytes = self.client.invoke("", "HostActiveDirectoryAuthentication", &self.mo_id, "LeaveCurrentDomain_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Deprecated as of vSphere API 8.0U3, and there is no replacement for it.
///
/// Lists installed trust anchor certificates for smart card authentication.
///
/// ***Required privileges:*** Host.Config.AuthenticationStore
///
/// ## Returns:
///
/// SSL certificates of trusted CAs in PEM format.
///
/// ## Errors:
///
/// ***HostConfigFault***: if the host configuration prevents the
/// certificates from being listed.
pub async fn list_smart_card_trust_anchors(&self) -> Result<Option<Vec<String>>> {
let bytes_opt = self.client.invoke_optional("", "HostActiveDirectoryAuthentication", &self.mo_id, "ListSmartCardTrustAnchors", None).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
None => Ok(None),
}
}
/// Deprecated please remove by fingerprint/digest instead.
///
/// Remove a smart card trust anchor certificate from the system.
///
/// ***Required privileges:*** Host.Config.AuthenticationStore
///
/// ## Parameters:
///
/// ### issuer
/// Certificate issuer
///
/// ### serial
/// Certificate serial number (decimal integer)
///
/// ## Errors:
///
/// ***HostConfigFault***: if the host configuration prevents the
/// certificate from being removed.
pub async fn remove_smart_card_trust_anchor(&self, issuer: &str, serial: &str) -> Result<()> {
let input = RemoveSmartCardTrustAnchorRequestType {issuer, serial, };
self.client.invoke_void("", "HostActiveDirectoryAuthentication", &self.mo_id, "RemoveSmartCardTrustAnchor", Some(&input)).await
}
/// Deprecated as of vSphere API 8.0U3, and there is no replacement for it.
///
/// Remove a smart card trust anchor certificate from the system by
/// fingerprint.
///
/// ***Required privileges:*** Host.Config.AuthenticationStore
///
/// ## Parameters:
///
/// ### fingerprint
/// Certificate fingerprint
///
/// ### digest
/// Digest function used to compute fingerprint. One of
/// *HostActiveDirectoryAuthenticationCertificateDigest_enum*.
///
/// ## Errors:
///
/// ***HostConfigFault***: if the host configuration prevents the
/// certificate from being removed.
pub async fn remove_smart_card_trust_anchor_by_fingerprint(&self, fingerprint: &str, digest: &str) -> Result<()> {
let input = RemoveSmartCardTrustAnchorByFingerprintRequestType {fingerprint, digest, };
self.client.invoke_void("", "HostActiveDirectoryAuthentication", &self.mo_id, "RemoveSmartCardTrustAnchorByFingerprint", Some(&input)).await
}
/// Remove a smart card trust anchor certificate from the system
///
/// ***Since:*** vSphere API Release 9.0.0.0
///
/// ***Required privileges:*** Host.Config.AuthenticationStore
///
/// ## Parameters:
///
/// ### certificate
/// PEM encoded certificate to remove
///
/// ## Errors:
///
/// ***HostConfigFault***: if the host configuration prevents the
/// certificate from being removed.
pub async fn remove_smart_card_trust_anchor_certificate(&self, certificate: &str) -> Result<()> {
let input = RemoveSmartCardTrustAnchorCertificateRequestType {certificate, };
self.client.invoke_void("", "HostActiveDirectoryAuthentication", &self.mo_id, "RemoveSmartCardTrustAnchorCertificate", Some(&input)).await
}
/// Deprecated as of vSphere API 8.0U3, and there is no replacement for it.
///
/// Replace the trust anchor certificates for smart card authentication.
///
/// ***Required privileges:*** Host.Config.AuthenticationStore
///
/// ## Parameters:
///
/// ### certs
/// List of trusted CA certificates in PEM format. If empty
/// then all existing trust anchors are removed.
pub async fn replace_smart_card_trust_anchors(&self, certs: Option<&[String]>) -> Result<()> {
let input = ReplaceSmartCardTrustAnchorsRequestType {certs, };
self.client.invoke_void("", "HostActiveDirectoryAuthentication", &self.mo_id, "ReplaceSmartCardTrustAnchors", Some(&input)).await
}
/// Information about the authentication store.
pub async fn info(&self) -> Result<Box<dyn crate::types::traits::HostAuthenticationStoreInfoTrait>> {
let pv_opt = self.client.fetch_property_raw("", "HostActiveDirectoryAuthentication", &self.mo_id, "info").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property info was empty".to_string()))?;
let result: Box<dyn crate::types::traits::HostAuthenticationStoreInfoTrait> = crate::core::client::extract_property(pv)?;
Ok(result)
}
}
struct ImportCertificateForCamRequestType<'a> {
cert_path: &'a str,
cam_server: &'a str,
}
impl<'a> miniserde::Serialize for ImportCertificateForCamRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(ImportCertificateForCamRequestTypeSer { data: self, seq: 0 }))
}
}
struct ImportCertificateForCamRequestTypeSer<'b, 'a> {
data: &'b ImportCertificateForCamRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for ImportCertificateForCamRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"ImportCertificateForCAMRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("certPath"), &self.data.cert_path as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("camServer"), &self.data.cam_server as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct InstallSmartCardTrustAnchorRequestType<'a> {
cert: &'a str,
}
impl<'a> miniserde::Serialize for InstallSmartCardTrustAnchorRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(InstallSmartCardTrustAnchorRequestTypeSer { data: self, seq: 0 }))
}
}
struct InstallSmartCardTrustAnchorRequestTypeSer<'b, 'a> {
data: &'b InstallSmartCardTrustAnchorRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for InstallSmartCardTrustAnchorRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"InstallSmartCardTrustAnchorRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("cert"), &self.data.cert as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct JoinDomainRequestType<'a> {
domain_name: &'a str,
user_name: &'a str,
password: &'a str,
}
impl<'a> miniserde::Serialize for JoinDomainRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(JoinDomainRequestTypeSer { data: self, seq: 0 }))
}
}
struct JoinDomainRequestTypeSer<'b, 'a> {
data: &'b JoinDomainRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for JoinDomainRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"JoinDomainRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("domainName"), &self.data.domain_name as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("userName"), &self.data.user_name as &dyn miniserde::Serialize)),
3 => return Some((std::borrow::Cow::Borrowed("password"), &self.data.password as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct JoinDomainWithCamRequestType<'a> {
domain_name: &'a str,
cam_server: &'a str,
}
impl<'a> miniserde::Serialize for JoinDomainWithCamRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(JoinDomainWithCamRequestTypeSer { data: self, seq: 0 }))
}
}
struct JoinDomainWithCamRequestTypeSer<'b, 'a> {
data: &'b JoinDomainWithCamRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for JoinDomainWithCamRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"JoinDomainWithCAMRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("domainName"), &self.data.domain_name as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("camServer"), &self.data.cam_server as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct LeaveCurrentDomainRequestType {
force: bool,
}
impl miniserde::Serialize for LeaveCurrentDomainRequestType {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(LeaveCurrentDomainRequestTypeSer { data: self, seq: 0 }))
}
}
struct LeaveCurrentDomainRequestTypeSer<'b> {
data: &'b LeaveCurrentDomainRequestType,
seq: usize,
}
impl<'b> miniserde::ser::Map for LeaveCurrentDomainRequestTypeSer<'b> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"LeaveCurrentDomainRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("force"), &self.data.force as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct RemoveSmartCardTrustAnchorRequestType<'a> {
issuer: &'a str,
serial: &'a str,
}
impl<'a> miniserde::Serialize for RemoveSmartCardTrustAnchorRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(RemoveSmartCardTrustAnchorRequestTypeSer { data: self, seq: 0 }))
}
}
struct RemoveSmartCardTrustAnchorRequestTypeSer<'b, 'a> {
data: &'b RemoveSmartCardTrustAnchorRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for RemoveSmartCardTrustAnchorRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"RemoveSmartCardTrustAnchorRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("issuer"), &self.data.issuer as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("serial"), &self.data.serial as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct RemoveSmartCardTrustAnchorByFingerprintRequestType<'a> {
fingerprint: &'a str,
digest: &'a str,
}
impl<'a> miniserde::Serialize for RemoveSmartCardTrustAnchorByFingerprintRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(RemoveSmartCardTrustAnchorByFingerprintRequestTypeSer { data: self, seq: 0 }))
}
}
struct RemoveSmartCardTrustAnchorByFingerprintRequestTypeSer<'b, 'a> {
data: &'b RemoveSmartCardTrustAnchorByFingerprintRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for RemoveSmartCardTrustAnchorByFingerprintRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"RemoveSmartCardTrustAnchorByFingerprintRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("fingerprint"), &self.data.fingerprint as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("digest"), &self.data.digest as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct RemoveSmartCardTrustAnchorCertificateRequestType<'a> {
certificate: &'a str,
}
impl<'a> miniserde::Serialize for RemoveSmartCardTrustAnchorCertificateRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(RemoveSmartCardTrustAnchorCertificateRequestTypeSer { data: self, seq: 0 }))
}
}
struct RemoveSmartCardTrustAnchorCertificateRequestTypeSer<'b, 'a> {
data: &'b RemoveSmartCardTrustAnchorCertificateRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for RemoveSmartCardTrustAnchorCertificateRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"RemoveSmartCardTrustAnchorCertificateRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("certificate"), &self.data.certificate as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct ReplaceSmartCardTrustAnchorsRequestType<'a> {
certs: Option<&'a [String]>,
}
impl<'a> miniserde::Serialize for ReplaceSmartCardTrustAnchorsRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(ReplaceSmartCardTrustAnchorsRequestTypeSer { data: self, seq: 0 }))
}
}
struct ReplaceSmartCardTrustAnchorsRequestTypeSer<'b, 'a> {
data: &'b ReplaceSmartCardTrustAnchorsRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for ReplaceSmartCardTrustAnchorsRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
loop {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"ReplaceSmartCardTrustAnchorsRequestType")),
1 => {
let Some(ref val) = self.data.certs else { continue; };
return Some((std::borrow::Cow::Borrowed("certs"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}