#[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 {}
#[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 {}
#[derive(Debug, Clone)]
pub enum ConfigurationKey {
AllowOfflineTxForUnknownId,
AuthorizationCacheEnabled,
AuthorizeRemoteTxRequests,
BlinkRepeat,
ClockAlignedDataInterval,
ConnectionTimeOut,
ConnectorPhaseRotation,
ConnectorPhaseRotationMaxLength,
GetConfigurationMaxKeys,
HeartbeatInterval,
LightIntensity,
LocalAuthorizeOffline,
LocalPreAuthorize,
MaxEnergyOnInvalidId,
MeterValuesAlignedData,
MeterValuesAlignedDataMaxLength,
MeterValuesSampledData,
MeterValuesSampledDataMaxLength,
MeterValueSampleInterval,
MinimumStatusDuration,
NumberOfConnectors,
ResetRetries,
StopTransactionOnEVSideDisconnect,
StopTransactionOnInvalidId,
StopTxnAlignedData,
StopTxnAlignedDataMaxLength,
StopTxnSampledData,
StopTxnSampledDataMaxLength,
SupportedFeatureProfiles,
SupportedFeatureProfilesMaxLength,
TransactionMessageAttempts,
TransactionMessageRetryInterval,
UnlockConnectorOnEVSideDisconnect,
WebSocketPingInterval,
LocalAuthListEnabled,
LocalAuthListMaxLength,
SendLocalListMaxLength,
ReserveConnectorZeroSupported,
ChargeProfileMaxStackLevel,
ChargingScheduleAllowedChargingRateUnit,
ChargingScheduleMaxPeriods,
ConnectorSwitch3to1PhaseSupported,
MaxChargingProfilesInstalled,
AdditionalRootCertificateCheck,
AuthorizationKey,
CertificateSignedMaxChainSize,
CertificateStoreMaxLength,
CpoName,
SecurityProfile,
SupportedFileTransferProtocols,
Other(heapless::String<50usize>),
}
impl ConfigurationKey {
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,
];
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(),
}
}
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,
}
}
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)
}
pub fn is_standardized(&self) -> bool {
!matches!(self, Self::Other(_))
}
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,
}
}
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,
}
}
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,
}
}
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)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum SecurityEvent {
FirmwareUpdated,
FailedToAuthenticateAtCsms,
CsmsFailedToAuthenticate,
SettingSystemTime,
StartupOfTheDevice,
ResetOrReboot,
SecurityLogWasCleared,
ReconfigurationOfSecurityParameters,
MemoryExhaustion,
InvalidMessages,
AttemptedReplayAttacks,
TamperDetectionActivated,
InvalidFirmwareSignature,
InvalidFirmwareSigningCertificate,
InvalidCsmsCertificate,
InvalidChargePointCertificate,
InvalidTLSVersion,
InvalidTLSCipherSuite,
MaintenanceLoginAccepted,
MaintenanceLoginFailed,
}
impl SecurityEvent {
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,
];
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",
}
}
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,
}
}
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)
}
}