ocpp-types 0.3.0

Strongly typed OCPP 1.6J, 2.0.1, and 2.1 message types for Rust. no_std, no alloc, embedded-friendly.
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
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
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
// @generated by ocpp-codegen from schemas/. Do not edit by hand -- run
// `scripts/generate.sh` to regenerate; manual changes will be overwritten.

//! Value sets the specification defines for fields its JSON schemas
//! type as bare strings.
//!
//! A field like `Variable.name` or `SecurityEventNotification.type` is
//! just `{"type": "string", "maxLength": N}` in the schema, with the
//! permitted values listed in a specification appendix instead. Those
//! appendix tables are vendored under `csv/` and generated into this
//! module.
//!
//! Nothing here changes a wire type. OCPP permits vendor-specific
//! values for these fields, so the message structs keep their
//! `heapless::String` fields and these enums sit alongside:
//!
//! # Open and closed value sets
//!
//! The sets a deployment realistically extends -- components,
//! variables, configuration keys -- are *open*: they carry an
//! `Other` variant, so a third-party value survives a
//! deserialize/serialize round trip. Use `from_wire_or_other` to
//! accept any value, `from_wire` to ask whether a value is one the
//! specification defines, and `is_standardized` to tell them apart
//! afterwards. Their equality and hashing compare the wire string,
//! so `Other("X")` and the `X` variant are one value.
//!
//! The rest are *closed*: one byte, `Copy`, and `from_wire`
//! returning `None` is the only outcome for an unrecognized value.
//! An open set is neither `Copy` nor one byte -- it is as wide as
//! the field's `maxLength` -- which is why it is opt-in per set.
//!
//! ```ignore
//! use ocpp_types::v21::common::Variable;
//! use ocpp_types::v21::standard::VariableName;
//!
//! let variable = Variable {
//!     name: heapless::String::try_from(VariableName::HeartbeatInterval.as_str()).unwrap(),
//!     custom_data: None,
//!     instance: None,
//! };
//! ```
/// Returned by `FromStr` for a value the specification doesn't
/// define.
///
/// Not in itself a protocol error: OCPP permits vendor-specific
/// components, variables, configuration keys and security events,
/// so receiving one of those is conformant. Use `from_wire` when an
/// unrecognized value is expected and `Option` reads better than
/// `Result`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct UnknownValue;
impl core::fmt::Display for UnknownValue {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        f.write_str("not a value defined by this OCPP version's specification")
    }
}
impl core::error::Error for UnknownValue {}
/// Returned when a value is longer than the specification's
/// `maxLength` for its field.
///
/// Only an open value set can produce this, and only from
/// `from_wire_or_other`: a value too long for the field is not one the
/// field could have carried, so it is rejected rather than truncated.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ValueTooLong;
impl core::fmt::Display for ValueTooLong {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        f.write_str("longer than this field's maxLength in the specification")
    }
}
impl core::error::Error for ValueTooLong {}
/// Standardized configuration keys for `GetConfiguration` / `ChangeConfiguration`.
///
/// The schema types `key` as a plain string; the spec lists these in "Standard Configuration Key Names & Values", extended by the Security Whitepaper.
///
/// An *open* set: values the specification doesn't define are carried
/// in [`Self::Other`] rather than rejected, so a deployment's own
/// values survive a deserialize/serialize round trip.
///
/// Comparison and hashing go through the wire string, not the variant,
/// so `Other("...")` holding a standardized value compares equal to
/// that variant.
#[derive(Debug, Clone)]
pub enum ConfigurationKey {
    /// If this key exists, the Charge Point supports Unknown Offline Authorization. If this key reports a value of true, Unknown Offline Authorization is enabled.
    AllowOfflineTxForUnknownId,
    /// If this key exists, the Charge Point supports an Authorization Cache. If this key reports a value of true, the Authorization Cache is enabled.
    AuthorizationCacheEnabled,
    /// Whether a remote request to start a transaction in the form of a RemoteStartTransaction.req message should be authorized beforehand like a local action to start a transaction.
    AuthorizeRemoteTxRequests,
    /// Number of times to blink Charge Point lighting when signalling.
    BlinkRepeat,
    /// Size (in seconds) of the clock-aligned data interval. This is the size (in seconds) of the set of evenly spaced aggregation intervals per day, starting at 00:00:00 (midnight).
    ClockAlignedDataInterval,
    /// Interval (from successful authorization) until incipient transaction is automatically cancelled, due to failure of EV driver to (correctly) insert the charging cable connector(s) into the appropriate socket(s).
    ConnectionTimeOut,
    /// The phase rotation per connector in respect to the connector's electrical meter (or if absent, the grid connection). Possible values per connector are RST, RTS, SRT, STR, TRS and TSR.
    ConnectorPhaseRotation,
    /// Maximum number of items in a ConnectorPhaseRotation Configuration Key.
    ConnectorPhaseRotationMaxLength,
    /// Maximum number of requested configuration keys in a GetConfiguration.req PDU.
    GetConfigurationMaxKeys,
    /// Interval (in seconds) of inactivity (no OCPP exchanges) with Central System after which the Charge Point should send a Heartbeat.req PDU.
    HeartbeatInterval,
    /// Percentage of maximum intensity at which to illuminate Charge Point lighting.
    LightIntensity,
    /// Whether the Charge Point, when offline, will start a transaction for locally-authorized identifiers.
    LocalAuthorizeOffline,
    /// Whether the Charge Point, when online, will start a transaction for locally-authorized identifiers without waiting for or requesting an Authorize.conf from the Central System.
    LocalPreAuthorize,
    /// Maximum energy in Wh delivered when an identifier is invalidated by the Central System after start of a transaction.
    MaxEnergyOnInvalidId,
    /// Clock-aligned measurand(s) to be included in a MeterValues.req PDU, every ClockAlignedDataInterval seconds.
    MeterValuesAlignedData,
    /// Maximum number of items in a MeterValuesAlignedData Configuration Key.
    MeterValuesAlignedDataMaxLength,
    /// Sampled measurands to be included in a MeterValues.req PDU, every MeterValueSampleInterval seconds. Where applicable, the Measurand is combined with the optional phase
    MeterValuesSampledData,
    /// Maximum number of items in a MeterValuesSampledData Configuration Key.
    MeterValuesSampledDataMaxLength,
    /// Interval (in seconds) between sampling of metering (or other) data, intended to be transmitted by MeterValues.req PDUs.
    MeterValueSampleInterval,
    /// The minimum duration that a Charge Point or Connector status is stable before a StatusNotification.req PDU is sent to the Central System.
    MinimumStatusDuration,
    /// The number of physical charging connectors of this Charge Point.
    NumberOfConnectors,
    /// Number of times to retry an unsuccessful reset of the Charge Point.
    ResetRetries,
    /// When set to true, the Charge Point SHALL administratively stop the transaction when the cable is unplugged from the EV.
    StopTransactionOnEVSideDisconnect,
    /// Whether the Charge Point will stop an ongoing transaction when it receives a non-Accepted authorization status in a StartTransaction.conf for this transaction.
    StopTransactionOnInvalidId,
    /// Clock-aligned periodic measurand(s) to be included in the TransactionData element of StopTransaction.req MeterValues.req PDU for every ClockAlignedDataInterval of the transaction.
    StopTxnAlignedData,
    /// Maximum number of items in a StopTxnAlignedData Configuration Key.
    StopTxnAlignedDataMaxLength,
    /// Sampled measurands to be included in the TransactionData element of StopTransaction.req PDU, every MeterValueSampleInterval seconds from the start of the transaction.
    StopTxnSampledData,
    /// Maximum number of items in a StopTxnSampledData Configuration Key.
    StopTxnSampledDataMaxLength,
    /// A list of supported Feature Profiles. Possible values are Core, FirmwareManagement, LocalAuthListManagement, Reservation, SmartCharging and RemoteTrigger.
    SupportedFeatureProfiles,
    /// Maximum number of items in a SupportedFeatureProfiles Configuration Key.
    SupportedFeatureProfilesMaxLength,
    /// How often the Charge Point should try to submit a transaction-related message when the Central System fails to process it.
    TransactionMessageAttempts,
    /// How long the Charge Point should wait before resubmitting a transaction-related message that the Central System failed to process.
    TransactionMessageRetryInterval,
    /// When set to true, the Charge Point SHALL unlock the cable on the Charge Point side when the cable is unplugged at the EV.
    UnlockConnectorOnEVSideDisconnect,
    /// Only relevant for websocket implementations. 0 disables client side websocket ping/pong. In this case there is either no ping/pong or the server initiates the ping and client responds with Pong.
    WebSocketPingInterval,
    /// Whether the Local Authorization List is enabled.
    LocalAuthListEnabled,
    /// Maximum number of identifications that can be stored in the Local Authorization List.
    LocalAuthListMaxLength,
    /// Maximum number of identifications that can be sent in a single SendLocalList.req.
    SendLocalListMaxLength,
    /// If this configuration key is present and set to true, Charge Point support reservations on connector 0.
    ReserveConnectorZeroSupported,
    /// Max StackLevel of a ChargingProfile. The number defined also indicates the max allowed number of installed charging schedules per Charging Profile Purposes.
    ChargeProfileMaxStackLevel,
    /// A list of supported quantities for use in a ChargingSchedule. Allowed values: Current and Power.
    ChargingScheduleAllowedChargingRateUnit,
    /// Maximum number of periods that may be defined per ChargingSchedule.
    ChargingScheduleMaxPeriods,
    /// If defined and true, this Charge Point support switching from 3 to 1 phase during a Transaction.
    ConnectorSwitch3to1PhaseSupported,
    /// Maximum number of Charging profiles installed at a time.
    MaxChargingProfilesInstalled,
    /// Whether a Charge Point should double-check whether a certificate is not revoked, in addition to the standard certificate chain check. When true, the Charge Point MUST verify the certificate against a Certificate Revocation List or an OCSP responder.
    AdditionalRootCertificateCheck,
    /// The basic authentication password used for HTTP Basic Authentication. Is write-only: reading it back returns no value. Minimal length is 16 bytes and it is not allowed to be set to an empty string.
    AuthorizationKey,
    /// This configuration key can be used to limit the size of the 'certificateChain' field from the CertificateSigned.req PDU. The value of this configuration key has a maximum limit of 10000 characters.
    CertificateSignedMaxChainSize,
    /// Maximum number of Root/CA certificates that can be installed in the Charge Point.
    CertificateStoreMaxLength,
    /// The Charge Point identity that is used as the value of the 'organizationName' field in the Certificate Signing Request when a Charge Point requests a new certificate.
    CpoName,
    /// This configuration key is used to set the security profile the Charge Point should use. It is not allowed to lower the security level of an existing connection.
    SecurityProfile,
    /// The transfer protocols supported for uploading a diagnostics or security log and for downloading firmware. Allowed values are FTP, FTPS, HTTP and HTTPS.
    SupportedFileTransferProtocols,
    /** A value this version's specification doesn't define -- typically a
 vendor-specific one, which OCPP explicitly permits.

 Bounded at 50 bytes, the same `maxLength` the wire field carries,
 so anything the field can hold this can hold. Prefer
 [`Self::from_wire_or_other`] over constructing this directly: it
 returns the standardized variant when the value is one, keeping a
 single representation per wire string.*/
    Other(heapless::String<50usize>),
}
impl ConfigurationKey {
    /// Every value this version's specification defines (50), in spec order.
    ///
    /// Does not include [`Self::Other`], which is unbounded in the
    /// values it can hold.
    pub const ALL: &'static [Self] = &[
        Self::AllowOfflineTxForUnknownId,
        Self::AuthorizationCacheEnabled,
        Self::AuthorizeRemoteTxRequests,
        Self::BlinkRepeat,
        Self::ClockAlignedDataInterval,
        Self::ConnectionTimeOut,
        Self::ConnectorPhaseRotation,
        Self::ConnectorPhaseRotationMaxLength,
        Self::GetConfigurationMaxKeys,
        Self::HeartbeatInterval,
        Self::LightIntensity,
        Self::LocalAuthorizeOffline,
        Self::LocalPreAuthorize,
        Self::MaxEnergyOnInvalidId,
        Self::MeterValuesAlignedData,
        Self::MeterValuesAlignedDataMaxLength,
        Self::MeterValuesSampledData,
        Self::MeterValuesSampledDataMaxLength,
        Self::MeterValueSampleInterval,
        Self::MinimumStatusDuration,
        Self::NumberOfConnectors,
        Self::ResetRetries,
        Self::StopTransactionOnEVSideDisconnect,
        Self::StopTransactionOnInvalidId,
        Self::StopTxnAlignedData,
        Self::StopTxnAlignedDataMaxLength,
        Self::StopTxnSampledData,
        Self::StopTxnSampledDataMaxLength,
        Self::SupportedFeatureProfiles,
        Self::SupportedFeatureProfilesMaxLength,
        Self::TransactionMessageAttempts,
        Self::TransactionMessageRetryInterval,
        Self::UnlockConnectorOnEVSideDisconnect,
        Self::WebSocketPingInterval,
        Self::LocalAuthListEnabled,
        Self::LocalAuthListMaxLength,
        Self::SendLocalListMaxLength,
        Self::ReserveConnectorZeroSupported,
        Self::ChargeProfileMaxStackLevel,
        Self::ChargingScheduleAllowedChargingRateUnit,
        Self::ChargingScheduleMaxPeriods,
        Self::ConnectorSwitch3to1PhaseSupported,
        Self::MaxChargingProfilesInstalled,
        Self::AdditionalRootCertificateCheck,
        Self::AuthorizationKey,
        Self::CertificateSignedMaxChainSize,
        Self::CertificateStoreMaxLength,
        Self::CpoName,
        Self::SecurityProfile,
        Self::SupportedFileTransferProtocols,
    ];
    /// This value as it appears on the wire.
    pub fn as_str(&self) -> &str {
        match self {
            Self::AllowOfflineTxForUnknownId => "AllowOfflineTxForUnknownId",
            Self::AuthorizationCacheEnabled => "AuthorizationCacheEnabled",
            Self::AuthorizeRemoteTxRequests => "AuthorizeRemoteTxRequests",
            Self::BlinkRepeat => "BlinkRepeat",
            Self::ClockAlignedDataInterval => "ClockAlignedDataInterval",
            Self::ConnectionTimeOut => "ConnectionTimeOut",
            Self::ConnectorPhaseRotation => "ConnectorPhaseRotation",
            Self::ConnectorPhaseRotationMaxLength => "ConnectorPhaseRotationMaxLength",
            Self::GetConfigurationMaxKeys => "GetConfigurationMaxKeys",
            Self::HeartbeatInterval => "HeartbeatInterval",
            Self::LightIntensity => "LightIntensity",
            Self::LocalAuthorizeOffline => "LocalAuthorizeOffline",
            Self::LocalPreAuthorize => "LocalPreAuthorize",
            Self::MaxEnergyOnInvalidId => "MaxEnergyOnInvalidId",
            Self::MeterValuesAlignedData => "MeterValuesAlignedData",
            Self::MeterValuesAlignedDataMaxLength => "MeterValuesAlignedDataMaxLength",
            Self::MeterValuesSampledData => "MeterValuesSampledData",
            Self::MeterValuesSampledDataMaxLength => "MeterValuesSampledDataMaxLength",
            Self::MeterValueSampleInterval => "MeterValueSampleInterval",
            Self::MinimumStatusDuration => "MinimumStatusDuration",
            Self::NumberOfConnectors => "NumberOfConnectors",
            Self::ResetRetries => "ResetRetries",
            Self::StopTransactionOnEVSideDisconnect => {
                "StopTransactionOnEVSideDisconnect"
            }
            Self::StopTransactionOnInvalidId => "StopTransactionOnInvalidId",
            Self::StopTxnAlignedData => "StopTxnAlignedData",
            Self::StopTxnAlignedDataMaxLength => "StopTxnAlignedDataMaxLength",
            Self::StopTxnSampledData => "StopTxnSampledData",
            Self::StopTxnSampledDataMaxLength => "StopTxnSampledDataMaxLength",
            Self::SupportedFeatureProfiles => "SupportedFeatureProfiles",
            Self::SupportedFeatureProfilesMaxLength => {
                "SupportedFeatureProfilesMaxLength"
            }
            Self::TransactionMessageAttempts => "TransactionMessageAttempts",
            Self::TransactionMessageRetryInterval => "TransactionMessageRetryInterval",
            Self::UnlockConnectorOnEVSideDisconnect => {
                "UnlockConnectorOnEVSideDisconnect"
            }
            Self::WebSocketPingInterval => "WebSocketPingInterval",
            Self::LocalAuthListEnabled => "LocalAuthListEnabled",
            Self::LocalAuthListMaxLength => "LocalAuthListMaxLength",
            Self::SendLocalListMaxLength => "SendLocalListMaxLength",
            Self::ReserveConnectorZeroSupported => "ReserveConnectorZeroSupported",
            Self::ChargeProfileMaxStackLevel => "ChargeProfileMaxStackLevel",
            Self::ChargingScheduleAllowedChargingRateUnit => {
                "ChargingScheduleAllowedChargingRateUnit"
            }
            Self::ChargingScheduleMaxPeriods => "ChargingScheduleMaxPeriods",
            Self::ConnectorSwitch3to1PhaseSupported => {
                "ConnectorSwitch3to1PhaseSupported"
            }
            Self::MaxChargingProfilesInstalled => "MaxChargingProfilesInstalled",
            Self::AdditionalRootCertificateCheck => "AdditionalRootCertificateCheck",
            Self::AuthorizationKey => "AuthorizationKey",
            Self::CertificateSignedMaxChainSize => "CertificateSignedMaxChainSize",
            Self::CertificateStoreMaxLength => "CertificateStoreMaxLength",
            Self::CpoName => "CpoName",
            Self::SecurityProfile => "SecurityProfile",
            Self::SupportedFileTransferProtocols => "SupportedFileTransferProtocols",
            Self::Other(value) => value.as_str(),
        }
    }
    /// Parses a wire value, returning `None` for values the
    /// specification doesn't define.
    ///
    /// Use this to ask "is this one of the spec's values?". To accept
    /// any value, use [`Self::from_wire_or_other`].
    pub fn from_wire(value: &str) -> Option<Self> {
        match value {
            "AllowOfflineTxForUnknownId" => Some(Self::AllowOfflineTxForUnknownId),
            "AuthorizationCacheEnabled" => Some(Self::AuthorizationCacheEnabled),
            "AuthorizeRemoteTxRequests" => Some(Self::AuthorizeRemoteTxRequests),
            "BlinkRepeat" => Some(Self::BlinkRepeat),
            "ClockAlignedDataInterval" => Some(Self::ClockAlignedDataInterval),
            "ConnectionTimeOut" => Some(Self::ConnectionTimeOut),
            "ConnectorPhaseRotation" => Some(Self::ConnectorPhaseRotation),
            "ConnectorPhaseRotationMaxLength" => {
                Some(Self::ConnectorPhaseRotationMaxLength)
            }
            "GetConfigurationMaxKeys" => Some(Self::GetConfigurationMaxKeys),
            "HeartbeatInterval" => Some(Self::HeartbeatInterval),
            "LightIntensity" => Some(Self::LightIntensity),
            "LocalAuthorizeOffline" => Some(Self::LocalAuthorizeOffline),
            "LocalPreAuthorize" => Some(Self::LocalPreAuthorize),
            "MaxEnergyOnInvalidId" => Some(Self::MaxEnergyOnInvalidId),
            "MeterValuesAlignedData" => Some(Self::MeterValuesAlignedData),
            "MeterValuesAlignedDataMaxLength" => {
                Some(Self::MeterValuesAlignedDataMaxLength)
            }
            "MeterValuesSampledData" => Some(Self::MeterValuesSampledData),
            "MeterValuesSampledDataMaxLength" => {
                Some(Self::MeterValuesSampledDataMaxLength)
            }
            "MeterValueSampleInterval" => Some(Self::MeterValueSampleInterval),
            "MinimumStatusDuration" => Some(Self::MinimumStatusDuration),
            "NumberOfConnectors" => Some(Self::NumberOfConnectors),
            "ResetRetries" => Some(Self::ResetRetries),
            "StopTransactionOnEVSideDisconnect" => {
                Some(Self::StopTransactionOnEVSideDisconnect)
            }
            "StopTransactionOnInvalidId" => Some(Self::StopTransactionOnInvalidId),
            "StopTxnAlignedData" => Some(Self::StopTxnAlignedData),
            "StopTxnAlignedDataMaxLength" => Some(Self::StopTxnAlignedDataMaxLength),
            "StopTxnSampledData" => Some(Self::StopTxnSampledData),
            "StopTxnSampledDataMaxLength" => Some(Self::StopTxnSampledDataMaxLength),
            "SupportedFeatureProfiles" => Some(Self::SupportedFeatureProfiles),
            "SupportedFeatureProfilesMaxLength" => {
                Some(Self::SupportedFeatureProfilesMaxLength)
            }
            "TransactionMessageAttempts" => Some(Self::TransactionMessageAttempts),
            "TransactionMessageRetryInterval" => {
                Some(Self::TransactionMessageRetryInterval)
            }
            "UnlockConnectorOnEVSideDisconnect" => {
                Some(Self::UnlockConnectorOnEVSideDisconnect)
            }
            "WebSocketPingInterval" => Some(Self::WebSocketPingInterval),
            "LocalAuthListEnabled" => Some(Self::LocalAuthListEnabled),
            "LocalAuthListMaxLength" => Some(Self::LocalAuthListMaxLength),
            "SendLocalListMaxLength" => Some(Self::SendLocalListMaxLength),
            "ReserveConnectorZeroSupported" => Some(Self::ReserveConnectorZeroSupported),
            "ChargeProfileMaxStackLevel" => Some(Self::ChargeProfileMaxStackLevel),
            "ChargingScheduleAllowedChargingRateUnit" => {
                Some(Self::ChargingScheduleAllowedChargingRateUnit)
            }
            "ChargingScheduleMaxPeriods" => Some(Self::ChargingScheduleMaxPeriods),
            "ConnectorSwitch3to1PhaseSupported" => {
                Some(Self::ConnectorSwitch3to1PhaseSupported)
            }
            "MaxChargingProfilesInstalled" => Some(Self::MaxChargingProfilesInstalled),
            "AdditionalRootCertificateCheck" => {
                Some(Self::AdditionalRootCertificateCheck)
            }
            "AuthorizationKey" => Some(Self::AuthorizationKey),
            "CertificateSignedMaxChainSize" => Some(Self::CertificateSignedMaxChainSize),
            "CertificateStoreMaxLength" => Some(Self::CertificateStoreMaxLength),
            "CpoName" => Some(Self::CpoName),
            "SecurityProfile" => Some(Self::SecurityProfile),
            "SupportedFileTransferProtocols" => {
                Some(Self::SupportedFileTransferProtocols)
            }
            _ => None,
        }
    }
    /// Parses any wire value, falling back to [`Self::Other`].
    ///
    /// Fails only if `value` is longer than the specification's
    /// `maxLength` for this field, in which case it isn't a value the
    /// field could have carried in the first place.
    pub fn from_wire_or_other(value: &str) -> Result<Self, ValueTooLong> {
        if let Some(standardized) = Self::from_wire(value) {
            return Ok(standardized);
        }
        heapless::String::try_from(value).map(Self::Other).map_err(|_| ValueTooLong)
    }
    /// Whether this is one of the values the specification defines,
    /// as opposed to a vendor's own.
    pub fn is_standardized(&self) -> bool {
        !matches!(self, Self::Other(_))
    }
    /// `R` (read-only), `RW` (read/write), or `W`, as stated by the spec.
    pub fn accessibility(&self) -> Option<&'static str> {
        match self {
            Self::AllowOfflineTxForUnknownId => Some("RW"),
            Self::AuthorizationCacheEnabled => Some("RW"),
            Self::AuthorizeRemoteTxRequests => Some("R or RW"),
            Self::BlinkRepeat => Some("RW"),
            Self::ClockAlignedDataInterval => Some("RW"),
            Self::ConnectionTimeOut => Some("RW"),
            Self::ConnectorPhaseRotation => Some("RW"),
            Self::ConnectorPhaseRotationMaxLength => Some("R"),
            Self::GetConfigurationMaxKeys => Some("R"),
            Self::HeartbeatInterval => Some("RW"),
            Self::LightIntensity => Some("RW"),
            Self::LocalAuthorizeOffline => Some("RW"),
            Self::LocalPreAuthorize => Some("RW"),
            Self::MaxEnergyOnInvalidId => Some("RW"),
            Self::MeterValuesAlignedData => Some("RW"),
            Self::MeterValuesAlignedDataMaxLength => Some("R"),
            Self::MeterValuesSampledData => Some("RW"),
            Self::MeterValuesSampledDataMaxLength => Some("R"),
            Self::MeterValueSampleInterval => Some("RW"),
            Self::MinimumStatusDuration => Some("RW"),
            Self::NumberOfConnectors => Some("R"),
            Self::ResetRetries => Some("RW"),
            Self::StopTransactionOnEVSideDisconnect => Some("RW"),
            Self::StopTransactionOnInvalidId => Some("RW"),
            Self::StopTxnAlignedData => Some("RW"),
            Self::StopTxnAlignedDataMaxLength => Some("R"),
            Self::StopTxnSampledData => Some("RW"),
            Self::StopTxnSampledDataMaxLength => Some("R"),
            Self::SupportedFeatureProfiles => Some("R"),
            Self::SupportedFeatureProfilesMaxLength => Some("R"),
            Self::TransactionMessageAttempts => Some("RW"),
            Self::TransactionMessageRetryInterval => Some("RW"),
            Self::UnlockConnectorOnEVSideDisconnect => Some("RW"),
            Self::WebSocketPingInterval => Some("RW"),
            Self::LocalAuthListEnabled => Some("RW"),
            Self::LocalAuthListMaxLength => Some("R"),
            Self::SendLocalListMaxLength => Some("R"),
            Self::ReserveConnectorZeroSupported => Some("R"),
            Self::ChargeProfileMaxStackLevel => Some("R"),
            Self::ChargingScheduleAllowedChargingRateUnit => Some("R"),
            Self::ChargingScheduleMaxPeriods => Some("R"),
            Self::ConnectorSwitch3to1PhaseSupported => Some("R"),
            Self::MaxChargingProfilesInstalled => Some("R"),
            Self::AdditionalRootCertificateCheck => Some("R"),
            Self::AuthorizationKey => Some("RW"),
            Self::CertificateSignedMaxChainSize => Some("R"),
            Self::CertificateStoreMaxLength => Some("R"),
            Self::CpoName => Some("RW"),
            Self::SecurityProfile => Some("RW"),
            Self::SupportedFileTransferProtocols => Some("R"),
            Self::Other(_) => None,
        }
    }
    /// The value's type as stated by the spec (e.g. `integer`, `boolean`, `CSL`).
    pub fn value_type(&self) -> Option<&'static str> {
        match self {
            Self::AllowOfflineTxForUnknownId => Some("boolean"),
            Self::AuthorizationCacheEnabled => Some("boolean"),
            Self::AuthorizeRemoteTxRequests => Some("boolean"),
            Self::BlinkRepeat => Some("integer"),
            Self::ClockAlignedDataInterval => Some("integer"),
            Self::ConnectionTimeOut => Some("integer"),
            Self::ConnectorPhaseRotation => Some("CSL"),
            Self::ConnectorPhaseRotationMaxLength => Some("integer"),
            Self::GetConfigurationMaxKeys => Some("integer"),
            Self::HeartbeatInterval => Some("integer"),
            Self::LightIntensity => Some("integer"),
            Self::LocalAuthorizeOffline => Some("boolean"),
            Self::LocalPreAuthorize => Some("boolean"),
            Self::MaxEnergyOnInvalidId => Some("integer"),
            Self::MeterValuesAlignedData => Some("CSL"),
            Self::MeterValuesAlignedDataMaxLength => Some("integer"),
            Self::MeterValuesSampledData => Some("CSL"),
            Self::MeterValuesSampledDataMaxLength => Some("integer"),
            Self::MeterValueSampleInterval => Some("integer"),
            Self::MinimumStatusDuration => Some("integer"),
            Self::NumberOfConnectors => Some("integer"),
            Self::ResetRetries => Some("integer"),
            Self::StopTransactionOnEVSideDisconnect => Some("boolean"),
            Self::StopTransactionOnInvalidId => Some("boolean"),
            Self::StopTxnAlignedData => Some("CSL"),
            Self::StopTxnAlignedDataMaxLength => Some("integer"),
            Self::StopTxnSampledData => Some("CSL"),
            Self::StopTxnSampledDataMaxLength => Some("integer"),
            Self::SupportedFeatureProfiles => Some("CSL"),
            Self::SupportedFeatureProfilesMaxLength => Some("integer"),
            Self::TransactionMessageAttempts => Some("integer"),
            Self::TransactionMessageRetryInterval => Some("integer"),
            Self::UnlockConnectorOnEVSideDisconnect => Some("boolean"),
            Self::WebSocketPingInterval => Some("integer"),
            Self::LocalAuthListEnabled => Some("boolean"),
            Self::LocalAuthListMaxLength => Some("integer"),
            Self::SendLocalListMaxLength => Some("integer"),
            Self::ReserveConnectorZeroSupported => Some("boolean"),
            Self::ChargeProfileMaxStackLevel => Some("integer"),
            Self::ChargingScheduleAllowedChargingRateUnit => Some("CSL"),
            Self::ChargingScheduleMaxPeriods => Some("integer"),
            Self::ConnectorSwitch3to1PhaseSupported => Some("boolean"),
            Self::MaxChargingProfilesInstalled => Some("integer"),
            Self::AdditionalRootCertificateCheck => Some("boolean"),
            Self::AuthorizationKey => Some("string"),
            Self::CertificateSignedMaxChainSize => Some("integer"),
            Self::CertificateStoreMaxLength => Some("integer"),
            Self::CpoName => Some("string"),
            Self::SecurityProfile => Some("integer"),
            Self::SupportedFileTransferProtocols => Some("CSL"),
            Self::Other(_) => None,
        }
    }
    /// Whether the spec requires every Charging Station to support this key.
    pub fn is_required(&self) -> bool {
        match self {
            Self::AllowOfflineTxForUnknownId => false,
            Self::AuthorizationCacheEnabled => false,
            Self::AuthorizeRemoteTxRequests => true,
            Self::BlinkRepeat => false,
            Self::ClockAlignedDataInterval => true,
            Self::ConnectionTimeOut => true,
            Self::ConnectorPhaseRotation => true,
            Self::ConnectorPhaseRotationMaxLength => false,
            Self::GetConfigurationMaxKeys => true,
            Self::HeartbeatInterval => true,
            Self::LightIntensity => false,
            Self::LocalAuthorizeOffline => true,
            Self::LocalPreAuthorize => true,
            Self::MaxEnergyOnInvalidId => false,
            Self::MeterValuesAlignedData => true,
            Self::MeterValuesAlignedDataMaxLength => false,
            Self::MeterValuesSampledData => true,
            Self::MeterValuesSampledDataMaxLength => false,
            Self::MeterValueSampleInterval => true,
            Self::MinimumStatusDuration => false,
            Self::NumberOfConnectors => true,
            Self::ResetRetries => true,
            Self::StopTransactionOnEVSideDisconnect => true,
            Self::StopTransactionOnInvalidId => true,
            Self::StopTxnAlignedData => true,
            Self::StopTxnAlignedDataMaxLength => false,
            Self::StopTxnSampledData => true,
            Self::StopTxnSampledDataMaxLength => false,
            Self::SupportedFeatureProfiles => true,
            Self::SupportedFeatureProfilesMaxLength => false,
            Self::TransactionMessageAttempts => true,
            Self::TransactionMessageRetryInterval => true,
            Self::UnlockConnectorOnEVSideDisconnect => true,
            Self::WebSocketPingInterval => false,
            Self::LocalAuthListEnabled => true,
            Self::LocalAuthListMaxLength => true,
            Self::SendLocalListMaxLength => true,
            Self::ReserveConnectorZeroSupported => false,
            Self::ChargeProfileMaxStackLevel => true,
            Self::ChargingScheduleAllowedChargingRateUnit => true,
            Self::ChargingScheduleMaxPeriods => true,
            Self::ConnectorSwitch3to1PhaseSupported => false,
            Self::MaxChargingProfilesInstalled => true,
            Self::AdditionalRootCertificateCheck => true,
            Self::AuthorizationKey => true,
            Self::CertificateSignedMaxChainSize => false,
            Self::CertificateStoreMaxLength => false,
            Self::CpoName => true,
            Self::SecurityProfile => true,
            Self::SupportedFileTransferProtocols => true,
            Self::Other(_) => false,
        }
    }
    /// The feature profile that defines the key (e.g. `Core`, `SmartCharging`, `Security`).
    pub fn feature_profile(&self) -> Option<&'static str> {
        match self {
            Self::AllowOfflineTxForUnknownId => Some("Core"),
            Self::AuthorizationCacheEnabled => Some("Core"),
            Self::AuthorizeRemoteTxRequests => Some("Core"),
            Self::BlinkRepeat => Some("Core"),
            Self::ClockAlignedDataInterval => Some("Core"),
            Self::ConnectionTimeOut => Some("Core"),
            Self::ConnectorPhaseRotation => Some("Core"),
            Self::ConnectorPhaseRotationMaxLength => Some("Core"),
            Self::GetConfigurationMaxKeys => Some("Core"),
            Self::HeartbeatInterval => Some("Core"),
            Self::LightIntensity => Some("Core"),
            Self::LocalAuthorizeOffline => Some("Core"),
            Self::LocalPreAuthorize => Some("Core"),
            Self::MaxEnergyOnInvalidId => Some("Core"),
            Self::MeterValuesAlignedData => Some("Core"),
            Self::MeterValuesAlignedDataMaxLength => Some("Core"),
            Self::MeterValuesSampledData => Some("Core"),
            Self::MeterValuesSampledDataMaxLength => Some("Core"),
            Self::MeterValueSampleInterval => Some("Core"),
            Self::MinimumStatusDuration => Some("Core"),
            Self::NumberOfConnectors => Some("Core"),
            Self::ResetRetries => Some("Core"),
            Self::StopTransactionOnEVSideDisconnect => Some("Core"),
            Self::StopTransactionOnInvalidId => Some("Core"),
            Self::StopTxnAlignedData => Some("Core"),
            Self::StopTxnAlignedDataMaxLength => Some("Core"),
            Self::StopTxnSampledData => Some("Core"),
            Self::StopTxnSampledDataMaxLength => Some("Core"),
            Self::SupportedFeatureProfiles => Some("Core"),
            Self::SupportedFeatureProfilesMaxLength => Some("Core"),
            Self::TransactionMessageAttempts => Some("Core"),
            Self::TransactionMessageRetryInterval => Some("Core"),
            Self::UnlockConnectorOnEVSideDisconnect => Some("Core"),
            Self::WebSocketPingInterval => Some("Core"),
            Self::LocalAuthListEnabled => Some("LocalAuthListManagement"),
            Self::LocalAuthListMaxLength => Some("LocalAuthListManagement"),
            Self::SendLocalListMaxLength => Some("LocalAuthListManagement"),
            Self::ReserveConnectorZeroSupported => Some("Reservation"),
            Self::ChargeProfileMaxStackLevel => Some("SmartCharging"),
            Self::ChargingScheduleAllowedChargingRateUnit => Some("SmartCharging"),
            Self::ChargingScheduleMaxPeriods => Some("SmartCharging"),
            Self::ConnectorSwitch3to1PhaseSupported => Some("SmartCharging"),
            Self::MaxChargingProfilesInstalled => Some("SmartCharging"),
            Self::AdditionalRootCertificateCheck => Some("Security"),
            Self::AuthorizationKey => Some("Security"),
            Self::CertificateSignedMaxChainSize => Some("Security"),
            Self::CertificateStoreMaxLength => Some("Security"),
            Self::CpoName => Some("Security"),
            Self::SecurityProfile => Some("Security"),
            Self::SupportedFileTransferProtocols => Some("Security"),
            Self::Other(_) => None,
        }
    }
}
impl core::fmt::Display for ConfigurationKey {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        f.write_str(self.as_str())
    }
}
impl core::str::FromStr for ConfigurationKey {
    type Err = ValueTooLong;
    fn from_str(value: &str) -> Result<Self, Self::Err> {
        Self::from_wire_or_other(value)
    }
}
impl PartialEq for ConfigurationKey {
    fn eq(&self, other: &Self) -> bool {
        self.as_str() == other.as_str()
    }
}
impl Eq for ConfigurationKey {}
impl core::hash::Hash for ConfigurationKey {
    fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
        self.as_str().hash(state);
    }
}
impl PartialOrd for ConfigurationKey {
    fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
        Some(self.cmp(other))
    }
}
impl Ord for ConfigurationKey {
    fn cmp(&self, other: &Self) -> core::cmp::Ordering {
        self.as_str().cmp(other.as_str())
    }
}
#[cfg(feature = "serde")]
impl serde::Serialize for ConfigurationKey {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(self.as_str())
    }
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for ConfigurationKey {
    fn deserialize<D: serde::Deserializer<'de>>(
        deserializer: D,
    ) -> Result<Self, D::Error> {
        struct Visitor;
        impl<'v> serde::de::Visitor<'v> for Visitor {
            type Value = ConfigurationKey;
            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
                f.write_str("a ConfigurationKey string")
            }
            fn visit_str<E: serde::de::Error>(
                self,
                value: &str,
            ) -> Result<Self::Value, E> {
                ConfigurationKey::from_wire_or_other(value)
                    .map_err(serde::de::Error::custom)
            }
        }
        deserializer.deserialize_str(Visitor)
    }
}
/// Standardized `SecurityEventNotification.type` values, from the 1.6 Security Whitepaper.
///
/// A *closed* set: it holds only the values the specification
/// defines. The wire field is a string, so a deployment can still
/// send something else -- `from_wire` returns `None` for that,
/// which is not by itself a protocol error.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum SecurityEvent {
    /// The Charge Point firmware is updated
    FirmwareUpdated,
    /// The authentication credentials provided by the Charge Point were rejected by the Central System
    FailedToAuthenticateAtCsms,
    /// The authentication credentials provided by the Central System were rejected by the Charge Point
    CsmsFailedToAuthenticate,
    /// The system time on the Charge Point was changed
    SettingSystemTime,
    /// The Charge Point has booted
    StartupOfTheDevice,
    /// The Charge Point was rebooted or reset
    ResetOrReboot,
    /// The security log was cleared
    SecurityLogWasCleared,
    /// Security parameters, such as keys or the security profile used, were changed
    ReconfigurationOfSecurityParameters,
    /// The Flash or RAM memory of the Charge Point is getting full
    MemoryExhaustion,
    /// The Charge Point has received messages that are not valid OCPP messages, if signed messages, signage invalid/incorrect
    InvalidMessages,
    /// The Charge Point has received a replayed message (other than the Central System trying to resend a message because there was for example a network problem)
    AttemptedReplayAttacks,
    /// The physical tamper detection sensor was triggered
    TamperDetectionActivated,
    /// The firmware signature is not valid
    InvalidFirmwareSignature,
    /// The certificate used to verify the firmware signature is not valid
    InvalidFirmwareSigningCertificate,
    /// The certificate that the Central System uses was not valid or could not be verified
    InvalidCsmsCertificate,
    /// The certificate sent to the Charge Point using the CertificateSigned.req message is not a valid certificate
    InvalidChargePointCertificate,
    /// The TLS version used by the Central System is lower than 1.2 and is not allowed by the security specification
    InvalidTLSVersion,
    /// The Central System did only allow connections using TLS cipher suites that are not allowed by the security specification
    InvalidTLSCipherSuite,
    /// Successful login to the local maintenance interface. It is recommended to include information like the user identification and the origin of the login attempt in the techInfo field
    MaintenanceLoginAccepted,
    /// Failed login attempt to the local maintenance interface. It is recommended to include information like the user identification and the origin of the login attempt in the techInfo field
    MaintenanceLoginFailed,
}
impl SecurityEvent {
    /// Every value this version's specification defines (20), in spec order.
    pub const ALL: &'static [Self] = &[
        Self::FirmwareUpdated,
        Self::FailedToAuthenticateAtCsms,
        Self::CsmsFailedToAuthenticate,
        Self::SettingSystemTime,
        Self::StartupOfTheDevice,
        Self::ResetOrReboot,
        Self::SecurityLogWasCleared,
        Self::ReconfigurationOfSecurityParameters,
        Self::MemoryExhaustion,
        Self::InvalidMessages,
        Self::AttemptedReplayAttacks,
        Self::TamperDetectionActivated,
        Self::InvalidFirmwareSignature,
        Self::InvalidFirmwareSigningCertificate,
        Self::InvalidCsmsCertificate,
        Self::InvalidChargePointCertificate,
        Self::InvalidTLSVersion,
        Self::InvalidTLSCipherSuite,
        Self::MaintenanceLoginAccepted,
        Self::MaintenanceLoginFailed,
    ];
    /// This value as it appears on the wire.
    pub const fn as_str(&self) -> &'static str {
        match self {
            Self::FirmwareUpdated => "FirmwareUpdated",
            Self::FailedToAuthenticateAtCsms => "FailedToAuthenticateAtCsms",
            Self::CsmsFailedToAuthenticate => "CsmsFailedToAuthenticate",
            Self::SettingSystemTime => "SettingSystemTime",
            Self::StartupOfTheDevice => "StartupOfTheDevice",
            Self::ResetOrReboot => "ResetOrReboot",
            Self::SecurityLogWasCleared => "SecurityLogWasCleared",
            Self::ReconfigurationOfSecurityParameters => {
                "ReconfigurationOfSecurityParameters"
            }
            Self::MemoryExhaustion => "MemoryExhaustion",
            Self::InvalidMessages => "InvalidMessages",
            Self::AttemptedReplayAttacks => "AttemptedReplayAttacks",
            Self::TamperDetectionActivated => "TamperDetectionActivated",
            Self::InvalidFirmwareSignature => "InvalidFirmwareSignature",
            Self::InvalidFirmwareSigningCertificate => {
                "InvalidFirmwareSigningCertificate"
            }
            Self::InvalidCsmsCertificate => "InvalidCsmsCertificate",
            Self::InvalidChargePointCertificate => "InvalidChargePointCertificate",
            Self::InvalidTLSVersion => "InvalidTLSVersion",
            Self::InvalidTLSCipherSuite => "InvalidTLSCipherSuite",
            Self::MaintenanceLoginAccepted => "MaintenanceLoginAccepted",
            Self::MaintenanceLoginFailed => "MaintenanceLoginFailed",
        }
    }
    /// Parses a wire value, returning `None` for values the
    /// specification doesn't define (e.g. a vendor's own).
    pub fn from_wire(value: &str) -> Option<Self> {
        match value {
            "FirmwareUpdated" => Some(Self::FirmwareUpdated),
            "FailedToAuthenticateAtCsms" => Some(Self::FailedToAuthenticateAtCsms),
            "CsmsFailedToAuthenticate" => Some(Self::CsmsFailedToAuthenticate),
            "SettingSystemTime" => Some(Self::SettingSystemTime),
            "StartupOfTheDevice" => Some(Self::StartupOfTheDevice),
            "ResetOrReboot" => Some(Self::ResetOrReboot),
            "SecurityLogWasCleared" => Some(Self::SecurityLogWasCleared),
            "ReconfigurationOfSecurityParameters" => {
                Some(Self::ReconfigurationOfSecurityParameters)
            }
            "MemoryExhaustion" => Some(Self::MemoryExhaustion),
            "InvalidMessages" => Some(Self::InvalidMessages),
            "AttemptedReplayAttacks" => Some(Self::AttemptedReplayAttacks),
            "TamperDetectionActivated" => Some(Self::TamperDetectionActivated),
            "InvalidFirmwareSignature" => Some(Self::InvalidFirmwareSignature),
            "InvalidFirmwareSigningCertificate" => {
                Some(Self::InvalidFirmwareSigningCertificate)
            }
            "InvalidCsmsCertificate" => Some(Self::InvalidCsmsCertificate),
            "InvalidChargePointCertificate" => Some(Self::InvalidChargePointCertificate),
            "InvalidTLSVersion" => Some(Self::InvalidTLSVersion),
            "InvalidTLSCipherSuite" => Some(Self::InvalidTLSCipherSuite),
            "MaintenanceLoginAccepted" => Some(Self::MaintenanceLoginAccepted),
            "MaintenanceLoginFailed" => Some(Self::MaintenanceLoginFailed),
            _ => None,
        }
    }
    /// Whether the Security Whitepaper marks this event critical, meaning it must be reported to the Central System even when not explicitly monitored.
    pub const fn is_critical(&self) -> bool {
        match self {
            Self::FirmwareUpdated => true,
            Self::FailedToAuthenticateAtCsms => false,
            Self::CsmsFailedToAuthenticate => false,
            Self::SettingSystemTime => true,
            Self::StartupOfTheDevice => true,
            Self::ResetOrReboot => true,
            Self::SecurityLogWasCleared => true,
            Self::ReconfigurationOfSecurityParameters => false,
            Self::MemoryExhaustion => true,
            Self::InvalidMessages => false,
            Self::AttemptedReplayAttacks => false,
            Self::TamperDetectionActivated => true,
            Self::InvalidFirmwareSignature => true,
            Self::InvalidFirmwareSigningCertificate => true,
            Self::InvalidCsmsCertificate => true,
            Self::InvalidChargePointCertificate => true,
            Self::InvalidTLSVersion => true,
            Self::InvalidTLSCipherSuite => true,
            Self::MaintenanceLoginAccepted => true,
            Self::MaintenanceLoginFailed => true,
        }
    }
}
impl core::fmt::Display for SecurityEvent {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        f.write_str(self.as_str())
    }
}
impl core::str::FromStr for SecurityEvent {
    type Err = UnknownValue;
    fn from_str(value: &str) -> Result<Self, Self::Err> {
        Self::from_wire(value).ok_or(UnknownValue)
    }
}