sunspec 0.8.0

SunSpec 1.1 compliant library with tokio support
Documentation
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
//! Set Operator Security Certificate
/// Set Operator Security Certificate
///
/// Security model for PKI
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
pub struct Model9 {
    /// Cert_UID
    ///
    /// User ID for this certificate
    pub cert_uid: u16,
    /// Cert_Role
    ///
    /// Role for this certificate
    pub cert_role: u16,
    /// Format
    ///
    /// Format of this certificate
    pub fmt: Fmt,
    /// Type
    ///
    /// Type of this certificate
    pub typ: Typ,
    /// Total Length
    ///
    /// Total Length of the Certificate
    ///
    /// Notes: In registers, zero padded.
    pub tot_ln: u16,
    /// Fragment length
    ///
    /// Length of this fragment
    ///
    /// Notes: Maximum fragment length is 80 registers
    pub frg_ln: u16,
    /// Frag1
    ///
    /// First word of this fragment
    pub frg1: u16,
    #[allow(missing_docs)]
    pub frg2: u16,
    #[allow(missing_docs)]
    pub frg3: u16,
    #[allow(missing_docs)]
    pub frg4: u16,
    #[allow(missing_docs)]
    pub frg5: u16,
    #[allow(missing_docs)]
    pub frg6: u16,
    #[allow(missing_docs)]
    pub frg7: u16,
    #[allow(missing_docs)]
    pub frg8: u16,
    #[allow(missing_docs)]
    pub frg9: u16,
    #[allow(missing_docs)]
    pub frg10: u16,
    #[allow(missing_docs)]
    pub frg11: u16,
    #[allow(missing_docs)]
    pub frg12: u16,
    #[allow(missing_docs)]
    pub frg13: u16,
    #[allow(missing_docs)]
    pub frg14: u16,
    #[allow(missing_docs)]
    pub frg15: u16,
    #[allow(missing_docs)]
    pub frg16: u16,
    #[allow(missing_docs)]
    pub frg17: u16,
    #[allow(missing_docs)]
    pub frg18: u16,
    #[allow(missing_docs)]
    pub frg19: u16,
    #[allow(missing_docs)]
    pub frg20: u16,
    #[allow(missing_docs)]
    pub frg21: u16,
    #[allow(missing_docs)]
    pub frg22: u16,
    #[allow(missing_docs)]
    pub frg23: u16,
    #[allow(missing_docs)]
    pub frg24: u16,
    #[allow(missing_docs)]
    pub frg25: u16,
    #[allow(missing_docs)]
    pub frg26: u16,
    #[allow(missing_docs)]
    pub frg27: u16,
    #[allow(missing_docs)]
    pub frg28: u16,
    #[allow(missing_docs)]
    pub frg29: u16,
    #[allow(missing_docs)]
    pub frg30: u16,
    #[allow(missing_docs)]
    pub frg31: u16,
    #[allow(missing_docs)]
    pub frg32: u16,
    #[allow(missing_docs)]
    pub frg33: u16,
    #[allow(missing_docs)]
    pub frg34: u16,
    #[allow(missing_docs)]
    pub frg35: u16,
    #[allow(missing_docs)]
    pub frg36: u16,
    #[allow(missing_docs)]
    pub frg37: u16,
    #[allow(missing_docs)]
    pub frg38: u16,
    #[allow(missing_docs)]
    pub frg39: u16,
    #[allow(missing_docs)]
    pub frg40: u16,
    #[allow(missing_docs)]
    pub frg41: u16,
    #[allow(missing_docs)]
    pub frg42: u16,
    #[allow(missing_docs)]
    pub frg43: u16,
    #[allow(missing_docs)]
    pub frg44: u16,
    #[allow(missing_docs)]
    pub frg45: u16,
    #[allow(missing_docs)]
    pub frg46: u16,
    #[allow(missing_docs)]
    pub frg47: u16,
    #[allow(missing_docs)]
    pub frg48: u16,
    #[allow(missing_docs)]
    pub frg49: u16,
    #[allow(missing_docs)]
    pub frg50: u16,
    #[allow(missing_docs)]
    pub frg51: u16,
    #[allow(missing_docs)]
    pub frg52: u16,
    #[allow(missing_docs)]
    pub frg53: u16,
    #[allow(missing_docs)]
    pub frg54: u16,
    #[allow(missing_docs)]
    pub frg55: u16,
    #[allow(missing_docs)]
    pub frg56: u16,
    #[allow(missing_docs)]
    pub frg57: u16,
    #[allow(missing_docs)]
    pub frg58: u16,
    #[allow(missing_docs)]
    pub frg59: u16,
    #[allow(missing_docs)]
    pub frg60: u16,
    #[allow(missing_docs)]
    pub frg61: u16,
    #[allow(missing_docs)]
    pub frg62: u16,
    #[allow(missing_docs)]
    pub frg63: u16,
    #[allow(missing_docs)]
    pub frg64: u16,
    #[allow(missing_docs)]
    pub frg65: u16,
    #[allow(missing_docs)]
    pub frg66: u16,
    #[allow(missing_docs)]
    pub frg67: u16,
    #[allow(missing_docs)]
    pub frg68: u16,
    #[allow(missing_docs)]
    pub frg69: u16,
    #[allow(missing_docs)]
    pub frg70: u16,
    #[allow(missing_docs)]
    pub frg71: u16,
    #[allow(missing_docs)]
    pub frg72: u16,
    #[allow(missing_docs)]
    pub frg73: u16,
    #[allow(missing_docs)]
    pub frg74: u16,
    #[allow(missing_docs)]
    pub frg75: u16,
    #[allow(missing_docs)]
    pub frg78: u16,
    #[allow(missing_docs)]
    pub frg79: u16,
    /// Frag80
    ///
    /// Last word of this fragment
    pub frg80: u16,
    /// Timestamp
    ///
    /// Timestamp value is the number of seconds since January 1, 2000
    pub ts: u32,
    /// Milliseconds
    ///
    /// Millisecond counter 0-999
    pub ms: u16,
    /// Sequence
    ///
    /// Sequence number of request
    ///
    /// Notes: Shall be advanced for each request
    pub seq: u16,
    /// UID
    ///
    /// User ID for the request signature
    pub uid: u16,
    /// Role
    ///
    /// Signing key used 0-5
    ///
    /// Notes: Each controller is assigned a key index that maps to their access control role
    pub role: u16,
    /// Algorithm
    ///
    /// Algorithm used to compute the digital signature
    ///
    /// Notes: For future proof
    pub alg: Alg,
    /// N
    ///
    /// Number of registers to follow for the certificate
    pub n: u16,
}
#[allow(missing_docs)]
impl Model9 {
    pub const CERT_UID: crate::Point<Self, u16> = crate::Point::new(0, 1, true);
    pub const CERT_ROLE: crate::Point<Self, u16> = crate::Point::new(1, 1, true);
    pub const FMT: crate::Point<Self, Fmt> = crate::Point::new(2, 1, true);
    pub const TYP: crate::Point<Self, Typ> = crate::Point::new(3, 1, true);
    pub const TOT_LN: crate::Point<Self, u16> = crate::Point::new(4, 1, true);
    pub const FRG_LN: crate::Point<Self, u16> = crate::Point::new(5, 1, true);
    pub const FRG1: crate::Point<Self, u16> = crate::Point::new(6, 1, true);
    pub const FRG2: crate::Point<Self, u16> = crate::Point::new(7, 1, true);
    pub const FRG3: crate::Point<Self, u16> = crate::Point::new(8, 1, true);
    pub const FRG4: crate::Point<Self, u16> = crate::Point::new(9, 1, true);
    pub const FRG5: crate::Point<Self, u16> = crate::Point::new(10, 1, true);
    pub const FRG6: crate::Point<Self, u16> = crate::Point::new(11, 1, true);
    pub const FRG7: crate::Point<Self, u16> = crate::Point::new(12, 1, true);
    pub const FRG8: crate::Point<Self, u16> = crate::Point::new(13, 1, true);
    pub const FRG9: crate::Point<Self, u16> = crate::Point::new(14, 1, true);
    pub const FRG10: crate::Point<Self, u16> = crate::Point::new(15, 1, true);
    pub const FRG11: crate::Point<Self, u16> = crate::Point::new(16, 1, true);
    pub const FRG12: crate::Point<Self, u16> = crate::Point::new(17, 1, true);
    pub const FRG13: crate::Point<Self, u16> = crate::Point::new(18, 1, true);
    pub const FRG14: crate::Point<Self, u16> = crate::Point::new(19, 1, true);
    pub const FRG15: crate::Point<Self, u16> = crate::Point::new(20, 1, true);
    pub const FRG16: crate::Point<Self, u16> = crate::Point::new(21, 1, true);
    pub const FRG17: crate::Point<Self, u16> = crate::Point::new(22, 1, true);
    pub const FRG18: crate::Point<Self, u16> = crate::Point::new(23, 1, true);
    pub const FRG19: crate::Point<Self, u16> = crate::Point::new(24, 1, true);
    pub const FRG20: crate::Point<Self, u16> = crate::Point::new(25, 1, true);
    pub const FRG21: crate::Point<Self, u16> = crate::Point::new(26, 1, true);
    pub const FRG22: crate::Point<Self, u16> = crate::Point::new(27, 1, true);
    pub const FRG23: crate::Point<Self, u16> = crate::Point::new(28, 1, true);
    pub const FRG24: crate::Point<Self, u16> = crate::Point::new(29, 1, true);
    pub const FRG25: crate::Point<Self, u16> = crate::Point::new(30, 1, true);
    pub const FRG26: crate::Point<Self, u16> = crate::Point::new(31, 1, true);
    pub const FRG27: crate::Point<Self, u16> = crate::Point::new(32, 1, true);
    pub const FRG28: crate::Point<Self, u16> = crate::Point::new(33, 1, true);
    pub const FRG29: crate::Point<Self, u16> = crate::Point::new(34, 1, true);
    pub const FRG30: crate::Point<Self, u16> = crate::Point::new(35, 1, true);
    pub const FRG31: crate::Point<Self, u16> = crate::Point::new(36, 1, true);
    pub const FRG32: crate::Point<Self, u16> = crate::Point::new(37, 1, true);
    pub const FRG33: crate::Point<Self, u16> = crate::Point::new(38, 1, true);
    pub const FRG34: crate::Point<Self, u16> = crate::Point::new(39, 1, true);
    pub const FRG35: crate::Point<Self, u16> = crate::Point::new(40, 1, true);
    pub const FRG36: crate::Point<Self, u16> = crate::Point::new(41, 1, true);
    pub const FRG37: crate::Point<Self, u16> = crate::Point::new(42, 1, true);
    pub const FRG38: crate::Point<Self, u16> = crate::Point::new(43, 1, true);
    pub const FRG39: crate::Point<Self, u16> = crate::Point::new(44, 1, true);
    pub const FRG40: crate::Point<Self, u16> = crate::Point::new(45, 1, true);
    pub const FRG41: crate::Point<Self, u16> = crate::Point::new(46, 1, true);
    pub const FRG42: crate::Point<Self, u16> = crate::Point::new(47, 1, true);
    pub const FRG43: crate::Point<Self, u16> = crate::Point::new(48, 1, true);
    pub const FRG44: crate::Point<Self, u16> = crate::Point::new(49, 1, true);
    pub const FRG45: crate::Point<Self, u16> = crate::Point::new(50, 1, true);
    pub const FRG46: crate::Point<Self, u16> = crate::Point::new(51, 1, true);
    pub const FRG47: crate::Point<Self, u16> = crate::Point::new(52, 1, true);
    pub const FRG48: crate::Point<Self, u16> = crate::Point::new(53, 1, true);
    pub const FRG49: crate::Point<Self, u16> = crate::Point::new(54, 1, true);
    pub const FRG50: crate::Point<Self, u16> = crate::Point::new(55, 1, true);
    pub const FRG51: crate::Point<Self, u16> = crate::Point::new(56, 1, true);
    pub const FRG52: crate::Point<Self, u16> = crate::Point::new(57, 1, true);
    pub const FRG53: crate::Point<Self, u16> = crate::Point::new(58, 1, true);
    pub const FRG54: crate::Point<Self, u16> = crate::Point::new(59, 1, true);
    pub const FRG55: crate::Point<Self, u16> = crate::Point::new(60, 1, true);
    pub const FRG56: crate::Point<Self, u16> = crate::Point::new(61, 1, true);
    pub const FRG57: crate::Point<Self, u16> = crate::Point::new(62, 1, true);
    pub const FRG58: crate::Point<Self, u16> = crate::Point::new(63, 1, true);
    pub const FRG59: crate::Point<Self, u16> = crate::Point::new(64, 1, true);
    pub const FRG60: crate::Point<Self, u16> = crate::Point::new(65, 1, true);
    pub const FRG61: crate::Point<Self, u16> = crate::Point::new(66, 1, true);
    pub const FRG62: crate::Point<Self, u16> = crate::Point::new(67, 1, true);
    pub const FRG63: crate::Point<Self, u16> = crate::Point::new(68, 1, true);
    pub const FRG64: crate::Point<Self, u16> = crate::Point::new(69, 1, true);
    pub const FRG65: crate::Point<Self, u16> = crate::Point::new(70, 1, true);
    pub const FRG66: crate::Point<Self, u16> = crate::Point::new(71, 1, true);
    pub const FRG67: crate::Point<Self, u16> = crate::Point::new(72, 1, true);
    pub const FRG68: crate::Point<Self, u16> = crate::Point::new(73, 1, true);
    pub const FRG69: crate::Point<Self, u16> = crate::Point::new(74, 1, true);
    pub const FRG70: crate::Point<Self, u16> = crate::Point::new(75, 1, true);
    pub const FRG71: crate::Point<Self, u16> = crate::Point::new(76, 1, true);
    pub const FRG72: crate::Point<Self, u16> = crate::Point::new(77, 1, true);
    pub const FRG73: crate::Point<Self, u16> = crate::Point::new(78, 1, true);
    pub const FRG74: crate::Point<Self, u16> = crate::Point::new(79, 1, true);
    pub const FRG75: crate::Point<Self, u16> = crate::Point::new(80, 1, true);
    pub const FRG78: crate::Point<Self, u16> = crate::Point::new(81, 1, true);
    pub const FRG79: crate::Point<Self, u16> = crate::Point::new(82, 1, true);
    pub const FRG80: crate::Point<Self, u16> = crate::Point::new(83, 1, true);
    pub const TS: crate::Point<Self, u32> = crate::Point::new(84, 2, true);
    pub const MS: crate::Point<Self, u16> = crate::Point::new(86, 1, true);
    pub const SEQ: crate::Point<Self, u16> = crate::Point::new(87, 1, true);
    pub const UID: crate::Point<Self, u16> = crate::Point::new(88, 1, true);
    pub const ROLE: crate::Point<Self, u16> = crate::Point::new(89, 1, true);
    pub const ALG: crate::Point<Self, Alg> = crate::Point::new(90, 1, true);
    pub const N: crate::Point<Self, u16> = crate::Point::new(91, 1, true);
}
impl crate::Model for Model9 {
    const ID: u16 = 9;
    fn from_data(data: &[u16]) -> Result<Self, crate::DecodeError> {
        Ok(Self {
            cert_uid: Self::CERT_UID.from_data(data)?,
            cert_role: Self::CERT_ROLE.from_data(data)?,
            fmt: Self::FMT.from_data(data)?,
            typ: Self::TYP.from_data(data)?,
            tot_ln: Self::TOT_LN.from_data(data)?,
            frg_ln: Self::FRG_LN.from_data(data)?,
            frg1: Self::FRG1.from_data(data)?,
            frg2: Self::FRG2.from_data(data)?,
            frg3: Self::FRG3.from_data(data)?,
            frg4: Self::FRG4.from_data(data)?,
            frg5: Self::FRG5.from_data(data)?,
            frg6: Self::FRG6.from_data(data)?,
            frg7: Self::FRG7.from_data(data)?,
            frg8: Self::FRG8.from_data(data)?,
            frg9: Self::FRG9.from_data(data)?,
            frg10: Self::FRG10.from_data(data)?,
            frg11: Self::FRG11.from_data(data)?,
            frg12: Self::FRG12.from_data(data)?,
            frg13: Self::FRG13.from_data(data)?,
            frg14: Self::FRG14.from_data(data)?,
            frg15: Self::FRG15.from_data(data)?,
            frg16: Self::FRG16.from_data(data)?,
            frg17: Self::FRG17.from_data(data)?,
            frg18: Self::FRG18.from_data(data)?,
            frg19: Self::FRG19.from_data(data)?,
            frg20: Self::FRG20.from_data(data)?,
            frg21: Self::FRG21.from_data(data)?,
            frg22: Self::FRG22.from_data(data)?,
            frg23: Self::FRG23.from_data(data)?,
            frg24: Self::FRG24.from_data(data)?,
            frg25: Self::FRG25.from_data(data)?,
            frg26: Self::FRG26.from_data(data)?,
            frg27: Self::FRG27.from_data(data)?,
            frg28: Self::FRG28.from_data(data)?,
            frg29: Self::FRG29.from_data(data)?,
            frg30: Self::FRG30.from_data(data)?,
            frg31: Self::FRG31.from_data(data)?,
            frg32: Self::FRG32.from_data(data)?,
            frg33: Self::FRG33.from_data(data)?,
            frg34: Self::FRG34.from_data(data)?,
            frg35: Self::FRG35.from_data(data)?,
            frg36: Self::FRG36.from_data(data)?,
            frg37: Self::FRG37.from_data(data)?,
            frg38: Self::FRG38.from_data(data)?,
            frg39: Self::FRG39.from_data(data)?,
            frg40: Self::FRG40.from_data(data)?,
            frg41: Self::FRG41.from_data(data)?,
            frg42: Self::FRG42.from_data(data)?,
            frg43: Self::FRG43.from_data(data)?,
            frg44: Self::FRG44.from_data(data)?,
            frg45: Self::FRG45.from_data(data)?,
            frg46: Self::FRG46.from_data(data)?,
            frg47: Self::FRG47.from_data(data)?,
            frg48: Self::FRG48.from_data(data)?,
            frg49: Self::FRG49.from_data(data)?,
            frg50: Self::FRG50.from_data(data)?,
            frg51: Self::FRG51.from_data(data)?,
            frg52: Self::FRG52.from_data(data)?,
            frg53: Self::FRG53.from_data(data)?,
            frg54: Self::FRG54.from_data(data)?,
            frg55: Self::FRG55.from_data(data)?,
            frg56: Self::FRG56.from_data(data)?,
            frg57: Self::FRG57.from_data(data)?,
            frg58: Self::FRG58.from_data(data)?,
            frg59: Self::FRG59.from_data(data)?,
            frg60: Self::FRG60.from_data(data)?,
            frg61: Self::FRG61.from_data(data)?,
            frg62: Self::FRG62.from_data(data)?,
            frg63: Self::FRG63.from_data(data)?,
            frg64: Self::FRG64.from_data(data)?,
            frg65: Self::FRG65.from_data(data)?,
            frg66: Self::FRG66.from_data(data)?,
            frg67: Self::FRG67.from_data(data)?,
            frg68: Self::FRG68.from_data(data)?,
            frg69: Self::FRG69.from_data(data)?,
            frg70: Self::FRG70.from_data(data)?,
            frg71: Self::FRG71.from_data(data)?,
            frg72: Self::FRG72.from_data(data)?,
            frg73: Self::FRG73.from_data(data)?,
            frg74: Self::FRG74.from_data(data)?,
            frg75: Self::FRG75.from_data(data)?,
            frg78: Self::FRG78.from_data(data)?,
            frg79: Self::FRG79.from_data(data)?,
            frg80: Self::FRG80.from_data(data)?,
            ts: Self::TS.from_data(data)?,
            ms: Self::MS.from_data(data)?,
            seq: Self::SEQ.from_data(data)?,
            uid: Self::UID.from_data(data)?,
            role: Self::ROLE.from_data(data)?,
            alg: Self::ALG.from_data(data)?,
            n: Self::N.from_data(data)?,
        })
    }
    fn addr(models: &crate::Models) -> crate::ModelAddr<Self> {
        models.m9
    }
}
/// Format
///
/// Format of this certificate
#[derive(Copy, Clone, Debug, Eq, PartialEq, strum::FromRepr)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
#[repr(u16)]
pub enum Fmt {
    #[allow(missing_docs)]
    None = 0,
    #[allow(missing_docs)]
    X509Pem = 1,
    #[allow(missing_docs)]
    X509Der = 2,
}
impl crate::Value for Fmt {
    fn decode(data: &[u16]) -> Result<Self, crate::DecodeError> {
        let value = u16::decode(data)?;
        Self::from_repr(value).ok_or(crate::DecodeError::InvalidEnumValue)
    }
    fn encode(self) -> Box<[u16]> {
        (self as u16).encode()
    }
}
impl crate::Value for Option<Fmt> {
    fn decode(data: &[u16]) -> Result<Self, crate::DecodeError> {
        let value = u16::decode(data)?;
        if value != 65535 {
            Ok(Some(
                Fmt::from_repr(value).ok_or(crate::DecodeError::InvalidEnumValue)?,
            ))
        } else {
            Ok(None)
        }
    }
    fn encode(self) -> Box<[u16]> {
        if let Some(value) = self {
            value.encode()
        } else {
            65535.encode()
        }
    }
}
/// Type
///
/// Type of this certificate
#[derive(Copy, Clone, Debug, Eq, PartialEq, strum::FromRepr)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
#[repr(u16)]
pub enum Typ {
    #[allow(missing_docs)]
    DevKeyPair = 0,
    #[allow(missing_docs)]
    DevSharedKey = 1,
    #[allow(missing_docs)]
    OperatorPub = 2,
    #[allow(missing_docs)]
    OperatorShared = 3,
    #[allow(missing_docs)]
    CaPub = 4,
}
impl crate::Value for Typ {
    fn decode(data: &[u16]) -> Result<Self, crate::DecodeError> {
        let value = u16::decode(data)?;
        Self::from_repr(value).ok_or(crate::DecodeError::InvalidEnumValue)
    }
    fn encode(self) -> Box<[u16]> {
        (self as u16).encode()
    }
}
impl crate::Value for Option<Typ> {
    fn decode(data: &[u16]) -> Result<Self, crate::DecodeError> {
        let value = u16::decode(data)?;
        if value != 65535 {
            Ok(Some(
                Typ::from_repr(value).ok_or(crate::DecodeError::InvalidEnumValue)?,
            ))
        } else {
            Ok(None)
        }
    }
    fn encode(self) -> Box<[u16]> {
        if let Some(value) = self {
            value.encode()
        } else {
            65535.encode()
        }
    }
}
/// Algorithm
///
/// Algorithm used to compute the digital signature
///
/// Notes: For future proof
#[derive(Copy, Clone, Debug, Eq, PartialEq, strum::FromRepr)]
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
#[repr(u16)]
pub enum Alg {
    /// Notes: For test purposes only
    None = 0,
    #[allow(missing_docs)]
    AesGmac64 = 1,
    #[allow(missing_docs)]
    Ecc256 = 2,
}
impl crate::Value for Alg {
    fn decode(data: &[u16]) -> Result<Self, crate::DecodeError> {
        let value = u16::decode(data)?;
        Self::from_repr(value).ok_or(crate::DecodeError::InvalidEnumValue)
    }
    fn encode(self) -> Box<[u16]> {
        (self as u16).encode()
    }
}
impl crate::Value for Option<Alg> {
    fn decode(data: &[u16]) -> Result<Self, crate::DecodeError> {
        let value = u16::decode(data)?;
        if value != 65535 {
            Ok(Some(
                Alg::from_repr(value).ok_or(crate::DecodeError::InvalidEnumValue)?,
            ))
        } else {
            Ok(None)
        }
    }
    fn encode(self) -> Box<[u16]> {
        if let Some(value) = self {
            value.encode()
        } else {
            65535.encode()
        }
    }
}