ocpp-kit 0.5.0

Open Charge Point Protocol (OCPP 1.6J, 2.0.1, 2.1) toolkit for Rust: typed messages, OCPP-J framing, a sans-I/O protocol engine, and transports for charging stations, CSMS and local controllers.
Documentation
// @generated by `cargo xtask appendix` from OCPP 2.1 Part 2 — Appendices v2.1 (2025-12-03).
//
// Only the interoperability surface is reproduced: names, data types and criticality. The
// appendix's prose descriptions are not copied, and the appendix itself is not redistributed.
// DO NOT EDIT — re-run the generator instead.

//! The standardized security events of OCPP 2.x, and which of them are critical.
//!
//! Appendix chapter 1: an implemented event is written to the security log, and an
//! implemented event marked **critical** is additionally pushed to the CSMS with
//! `SecurityEventNotification`. Deciding *which* events to implement is the
//! application's business; knowing which of them are critical is not.

ocpp_enum! {
    /// A security event from the standardized list.
    ///
    /// The list is explicitly non-exhaustive: a vendor-specific event is carried in
    /// `UnknownValue`, and the specification asks that a standardized event be used
    /// wherever one matches.
    SecurityEvent {
        /// `FirmwareUpdated`.
        FirmwareUpdated = "FirmwareUpdated",
        /// `FailedToAuthenticateAtCsms`.
        FailedToAuthenticateAtCsms = "FailedToAuthenticateAtCsms",
        /// `CsmsFailedToAuthenticate`.
        CsmsFailedToAuthenticate = "CsmsFailedToAuthenticate",
        /// `SettingSystemTime`.
        SettingSystemTime = "SettingSystemTime",
        /// `StartupOfTheDevice`.
        StartupOfTheDevice = "StartupOfTheDevice",
        /// `ResetOrReboot`.
        ResetOrReboot = "ResetOrReboot",
        /// `SecurityLogWasCleared`.
        SecurityLogWasCleared = "SecurityLogWasCleared",
        /// `ReconfigurationOfSecurityParameters`.
        ReconfigurationOfSecurityParameters = "ReconfigurationOfSecurityParameters",
        /// `MemoryExhaustion`.
        MemoryExhaustion = "MemoryExhaustion",
        /// `InvalidMessages`.
        InvalidMessages = "InvalidMessages",
        /// `AttemptedReplayAttacks`.
        AttemptedReplayAttacks = "AttemptedReplayAttacks",
        /// `TamperDetectionActivated`.
        TamperDetectionActivated = "TamperDetectionActivated",
        /// `InvalidFirmwareSignature`.
        InvalidFirmwareSignature = "InvalidFirmwareSignature",
        /// `InvalidFirmwareSigningCertificate`.
        InvalidFirmwareSigningCertificate = "InvalidFirmwareSigningCertificate",
        /// `InvalidCsmsCertificate`.
        InvalidCsmsCertificate = "InvalidCsmsCertificate",
        /// `InvalidChargingStationCertificate`.
        InvalidChargingStationCertificate = "InvalidChargingStationCertificate",
        /// `DiscardedRenewedClientCertificate`.
        DiscardedRenewedClientCertificate = "DiscardedRenewedClientCertificate",
        /// `InvalidTLSVersion`.
        InvalidTLSVersion = "InvalidTLSVersion",
        /// `InvalidTLSCipherSuite`.
        InvalidTLSCipherSuite = "InvalidTLSCipherSuite",
        /// `MaintenanceLoginAccepted`.
        MaintenanceLoginAccepted = "MaintenanceLoginAccepted",
        /// `MaintenanceLoginFailed`.
        MaintenanceLoginFailed = "MaintenanceLoginFailed",
    }
}

impl SecurityEvent {
    /// Whether the event must be pushed to the CSMS as well as logged.
    ///
    /// A vendor-specific event is treated as critical: the safe default is to report it.
    #[must_use]
    #[allow(clippy::match_same_arms)]
    pub 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::InvalidChargingStationCertificate => true,
            Self::DiscardedRenewedClientCertificate => true,
            Self::InvalidTLSVersion => true,
            Self::InvalidTLSCipherSuite => true,
            Self::MaintenanceLoginAccepted => true,
            Self::MaintenanceLoginFailed => true,
            Self::UnknownValue(_) => true,
        }
    }

    /// Every event the specification defines as critical.
    #[must_use]
    pub fn critical() -> alloc::vec::Vec<Self> {
        Self::VARIANTS
            .iter()
            .map(|name| Self::from_wire(name))
            .filter(Self::is_critical)
            .collect()
    }
}