#![allow(clippy::large_enum_variant)]
use ocpp_core::validate::Violation;
use crate::messages::*;
impl ocpp_core::Request for AFRRSignalRequest {
const ACTION: &'static str = "AFRRSignal";
type Response = AFRRSignalResponse;
}
impl ocpp_core::Request for AdjustPeriodicEventStreamRequest {
const ACTION: &'static str = "AdjustPeriodicEventStream";
type Response = AdjustPeriodicEventStreamResponse;
}
impl ocpp_core::Request for AuthorizeRequest {
const ACTION: &'static str = "Authorize";
type Response = AuthorizeResponse;
}
impl ocpp_core::Request for BatterySwapRequest {
const ACTION: &'static str = "BatterySwap";
type Response = BatterySwapResponse;
}
impl ocpp_core::Request for BootNotificationRequest {
const ACTION: &'static str = "BootNotification";
type Response = BootNotificationResponse;
}
impl ocpp_core::Request for CancelReservationRequest {
const ACTION: &'static str = "CancelReservation";
type Response = CancelReservationResponse;
}
impl ocpp_core::Request for CertificateSignedRequest {
const ACTION: &'static str = "CertificateSigned";
type Response = CertificateSignedResponse;
}
impl ocpp_core::Request for ChangeAvailabilityRequest {
const ACTION: &'static str = "ChangeAvailability";
type Response = ChangeAvailabilityResponse;
}
impl ocpp_core::Request for ChangeTransactionTariffRequest {
const ACTION: &'static str = "ChangeTransactionTariff";
type Response = ChangeTransactionTariffResponse;
}
impl ocpp_core::Request for ClearCacheRequest {
const ACTION: &'static str = "ClearCache";
type Response = ClearCacheResponse;
}
impl ocpp_core::Request for ClearChargingProfileRequest {
const ACTION: &'static str = "ClearChargingProfile";
type Response = ClearChargingProfileResponse;
}
impl ocpp_core::Request for ClearDERControlRequest {
const ACTION: &'static str = "ClearDERControl";
type Response = ClearDERControlResponse;
}
impl ocpp_core::Request for ClearDisplayMessageRequest {
const ACTION: &'static str = "ClearDisplayMessage";
type Response = ClearDisplayMessageResponse;
}
impl ocpp_core::Request for ClearTariffsRequest {
const ACTION: &'static str = "ClearTariffs";
type Response = ClearTariffsResponse;
}
impl ocpp_core::Request for ClearVariableMonitoringRequest {
const ACTION: &'static str = "ClearVariableMonitoring";
type Response = ClearVariableMonitoringResponse;
}
impl ocpp_core::Request for ClearedChargingLimitRequest {
const ACTION: &'static str = "ClearedChargingLimit";
type Response = ClearedChargingLimitResponse;
}
impl ocpp_core::Request for ClosePeriodicEventStreamRequest {
const ACTION: &'static str = "ClosePeriodicEventStream";
type Response = ClosePeriodicEventStreamResponse;
}
impl ocpp_core::Request for CostUpdatedRequest {
const ACTION: &'static str = "CostUpdated";
type Response = CostUpdatedResponse;
}
impl ocpp_core::Request for CustomerInformationRequest {
const ACTION: &'static str = "CustomerInformation";
type Response = CustomerInformationResponse;
}
impl ocpp_core::Request for DataTransferRequest {
const ACTION: &'static str = "DataTransfer";
type Response = DataTransferResponse;
}
impl ocpp_core::Request for DeleteCertificateRequest {
const ACTION: &'static str = "DeleteCertificate";
type Response = DeleteCertificateResponse;
}
impl ocpp_core::Request for FirmwareStatusNotificationRequest {
const ACTION: &'static str = "FirmwareStatusNotification";
type Response = FirmwareStatusNotificationResponse;
}
impl ocpp_core::Request for Get15118EVCertificateRequest {
const ACTION: &'static str = "Get15118EVCertificate";
type Response = Get15118EVCertificateResponse;
}
impl ocpp_core::Request for GetBaseReportRequest {
const ACTION: &'static str = "GetBaseReport";
type Response = GetBaseReportResponse;
}
impl ocpp_core::Request for GetCertificateChainStatusRequest {
const ACTION: &'static str = "GetCertificateChainStatus";
type Response = GetCertificateChainStatusResponse;
}
impl ocpp_core::Request for GetCertificateStatusRequest {
const ACTION: &'static str = "GetCertificateStatus";
type Response = GetCertificateStatusResponse;
}
impl ocpp_core::Request for GetChargingProfilesRequest {
const ACTION: &'static str = "GetChargingProfiles";
type Response = GetChargingProfilesResponse;
}
impl ocpp_core::Request for GetCompositeScheduleRequest {
const ACTION: &'static str = "GetCompositeSchedule";
type Response = GetCompositeScheduleResponse;
}
impl ocpp_core::Request for GetDERControlRequest {
const ACTION: &'static str = "GetDERControl";
type Response = GetDERControlResponse;
}
impl ocpp_core::Request for GetDisplayMessagesRequest {
const ACTION: &'static str = "GetDisplayMessages";
type Response = GetDisplayMessagesResponse;
}
impl ocpp_core::Request for GetInstalledCertificateIdsRequest {
const ACTION: &'static str = "GetInstalledCertificateIds";
type Response = GetInstalledCertificateIdsResponse;
}
impl ocpp_core::Request for GetLocalListVersionRequest {
const ACTION: &'static str = "GetLocalListVersion";
type Response = GetLocalListVersionResponse;
}
impl ocpp_core::Request for GetLogRequest {
const ACTION: &'static str = "GetLog";
type Response = GetLogResponse;
}
impl ocpp_core::Request for GetMonitoringReportRequest {
const ACTION: &'static str = "GetMonitoringReport";
type Response = GetMonitoringReportResponse;
}
impl ocpp_core::Request for GetPeriodicEventStreamRequest {
const ACTION: &'static str = "GetPeriodicEventStream";
type Response = GetPeriodicEventStreamResponse;
}
impl ocpp_core::Request for GetReportRequest {
const ACTION: &'static str = "GetReport";
type Response = GetReportResponse;
}
impl ocpp_core::Request for GetTariffsRequest {
const ACTION: &'static str = "GetTariffs";
type Response = GetTariffsResponse;
}
impl ocpp_core::Request for GetTransactionStatusRequest {
const ACTION: &'static str = "GetTransactionStatus";
type Response = GetTransactionStatusResponse;
}
impl ocpp_core::Request for GetVariablesRequest {
const ACTION: &'static str = "GetVariables";
type Response = GetVariablesResponse;
}
impl ocpp_core::Request for HeartbeatRequest {
const ACTION: &'static str = "Heartbeat";
type Response = HeartbeatResponse;
}
impl ocpp_core::Request for InstallCertificateRequest {
const ACTION: &'static str = "InstallCertificate";
type Response = InstallCertificateResponse;
}
impl ocpp_core::Request for LogStatusNotificationRequest {
const ACTION: &'static str = "LogStatusNotification";
type Response = LogStatusNotificationResponse;
}
impl ocpp_core::Request for MeterValuesRequest {
const ACTION: &'static str = "MeterValues";
type Response = MeterValuesResponse;
}
impl ocpp_core::Request for NotifyAllowedEnergyTransferRequest {
const ACTION: &'static str = "NotifyAllowedEnergyTransfer";
type Response = NotifyAllowedEnergyTransferResponse;
}
impl ocpp_core::Request for NotifyChargingLimitRequest {
const ACTION: &'static str = "NotifyChargingLimit";
type Response = NotifyChargingLimitResponse;
}
impl ocpp_core::Request for NotifyCustomerInformationRequest {
const ACTION: &'static str = "NotifyCustomerInformation";
type Response = NotifyCustomerInformationResponse;
}
impl ocpp_core::Request for NotifyDERAlarmRequest {
const ACTION: &'static str = "NotifyDERAlarm";
type Response = NotifyDERAlarmResponse;
}
impl ocpp_core::Request for NotifyDERStartStopRequest {
const ACTION: &'static str = "NotifyDERStartStop";
type Response = NotifyDERStartStopResponse;
}
impl ocpp_core::Request for NotifyDisplayMessagesRequest {
const ACTION: &'static str = "NotifyDisplayMessages";
type Response = NotifyDisplayMessagesResponse;
}
impl ocpp_core::Request for NotifyEVChargingNeedsRequest {
const ACTION: &'static str = "NotifyEVChargingNeeds";
type Response = NotifyEVChargingNeedsResponse;
}
impl ocpp_core::Request for NotifyEVChargingScheduleRequest {
const ACTION: &'static str = "NotifyEVChargingSchedule";
type Response = NotifyEVChargingScheduleResponse;
}
impl ocpp_core::Request for NotifyEventRequest {
const ACTION: &'static str = "NotifyEvent";
type Response = NotifyEventResponse;
}
impl ocpp_core::Request for NotifyMonitoringReportRequest {
const ACTION: &'static str = "NotifyMonitoringReport";
type Response = NotifyMonitoringReportResponse;
}
impl ocpp_core::Request for NotifyPriorityChargingRequest {
const ACTION: &'static str = "NotifyPriorityCharging";
type Response = NotifyPriorityChargingResponse;
}
impl ocpp_core::Request for NotifyReportRequest {
const ACTION: &'static str = "NotifyReport";
type Response = NotifyReportResponse;
}
impl ocpp_core::Request for NotifySettlementRequest {
const ACTION: &'static str = "NotifySettlement";
type Response = NotifySettlementResponse;
}
impl ocpp_core::Request for NotifyWebPaymentStartedRequest {
const ACTION: &'static str = "NotifyWebPaymentStarted";
type Response = NotifyWebPaymentStartedResponse;
}
impl ocpp_core::Request for OpenPeriodicEventStreamRequest {
const ACTION: &'static str = "OpenPeriodicEventStream";
type Response = OpenPeriodicEventStreamResponse;
}
impl ocpp_core::Request for PublishFirmwareRequest {
const ACTION: &'static str = "PublishFirmware";
type Response = PublishFirmwareResponse;
}
impl ocpp_core::Request for PublishFirmwareStatusNotificationRequest {
const ACTION: &'static str = "PublishFirmwareStatusNotification";
type Response = PublishFirmwareStatusNotificationResponse;
}
impl ocpp_core::Request for PullDynamicScheduleUpdateRequest {
const ACTION: &'static str = "PullDynamicScheduleUpdate";
type Response = PullDynamicScheduleUpdateResponse;
}
impl ocpp_core::Request for ReportChargingProfilesRequest {
const ACTION: &'static str = "ReportChargingProfiles";
type Response = ReportChargingProfilesResponse;
}
impl ocpp_core::Request for ReportDERControlRequest {
const ACTION: &'static str = "ReportDERControl";
type Response = ReportDERControlResponse;
}
impl ocpp_core::Request for RequestBatterySwapRequest {
const ACTION: &'static str = "RequestBatterySwap";
type Response = RequestBatterySwapResponse;
}
impl ocpp_core::Request for RequestStartTransactionRequest {
const ACTION: &'static str = "RequestStartTransaction";
type Response = RequestStartTransactionResponse;
}
impl ocpp_core::Request for RequestStopTransactionRequest {
const ACTION: &'static str = "RequestStopTransaction";
type Response = RequestStopTransactionResponse;
}
impl ocpp_core::Request for ReservationStatusUpdateRequest {
const ACTION: &'static str = "ReservationStatusUpdate";
type Response = ReservationStatusUpdateResponse;
}
impl ocpp_core::Request for ReserveNowRequest {
const ACTION: &'static str = "ReserveNow";
type Response = ReserveNowResponse;
}
impl ocpp_core::Request for ResetRequest {
const ACTION: &'static str = "Reset";
type Response = ResetResponse;
}
impl ocpp_core::Request for SecurityEventNotificationRequest {
const ACTION: &'static str = "SecurityEventNotification";
type Response = SecurityEventNotificationResponse;
}
impl ocpp_core::Request for SendLocalListRequest {
const ACTION: &'static str = "SendLocalList";
type Response = SendLocalListResponse;
}
impl ocpp_core::Request for SetChargingProfileRequest {
const ACTION: &'static str = "SetChargingProfile";
type Response = SetChargingProfileResponse;
}
impl ocpp_core::Request for SetDERControlRequest {
const ACTION: &'static str = "SetDERControl";
type Response = SetDERControlResponse;
}
impl ocpp_core::Request for SetDefaultTariffRequest {
const ACTION: &'static str = "SetDefaultTariff";
type Response = SetDefaultTariffResponse;
}
impl ocpp_core::Request for SetDisplayMessageRequest {
const ACTION: &'static str = "SetDisplayMessage";
type Response = SetDisplayMessageResponse;
}
impl ocpp_core::Request for SetMonitoringBaseRequest {
const ACTION: &'static str = "SetMonitoringBase";
type Response = SetMonitoringBaseResponse;
}
impl ocpp_core::Request for SetMonitoringLevelRequest {
const ACTION: &'static str = "SetMonitoringLevel";
type Response = SetMonitoringLevelResponse;
}
impl ocpp_core::Request for SetNetworkProfileRequest {
const ACTION: &'static str = "SetNetworkProfile";
type Response = SetNetworkProfileResponse;
}
impl ocpp_core::Request for SetVariableMonitoringRequest {
const ACTION: &'static str = "SetVariableMonitoring";
type Response = SetVariableMonitoringResponse;
}
impl ocpp_core::Request for SetVariablesRequest {
const ACTION: &'static str = "SetVariables";
type Response = SetVariablesResponse;
}
impl ocpp_core::Request for SignCertificateRequest {
const ACTION: &'static str = "SignCertificate";
type Response = SignCertificateResponse;
}
impl ocpp_core::Request for StatusNotificationRequest {
const ACTION: &'static str = "StatusNotification";
type Response = StatusNotificationResponse;
}
impl ocpp_core::Request for TransactionEventRequest {
const ACTION: &'static str = "TransactionEvent";
type Response = TransactionEventResponse;
}
impl ocpp_core::Request for TriggerMessageRequest {
const ACTION: &'static str = "TriggerMessage";
type Response = TriggerMessageResponse;
}
impl ocpp_core::Request for UnlockConnectorRequest {
const ACTION: &'static str = "UnlockConnector";
type Response = UnlockConnectorResponse;
}
impl ocpp_core::Request for UnpublishFirmwareRequest {
const ACTION: &'static str = "UnpublishFirmware";
type Response = UnpublishFirmwareResponse;
}
impl ocpp_core::Request for UpdateDynamicScheduleRequest {
const ACTION: &'static str = "UpdateDynamicSchedule";
type Response = UpdateDynamicScheduleResponse;
}
impl ocpp_core::Request for UpdateFirmwareRequest {
const ACTION: &'static str = "UpdateFirmware";
type Response = UpdateFirmwareResponse;
}
impl ocpp_core::Request for UsePriorityChargingRequest {
const ACTION: &'static str = "UsePriorityCharging";
type Response = UsePriorityChargingResponse;
}
impl ocpp_core::Request for VatNumberValidationRequest {
const ACTION: &'static str = "VatNumberValidation";
type Response = VatNumberValidationResponse;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Direction {
StationToCsms,
CsmsToStation,
Both,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Action {
AFRRSignal,
AdjustPeriodicEventStream,
Authorize,
BatterySwap,
BootNotification,
CancelReservation,
CertificateSigned,
ChangeAvailability,
ChangeTransactionTariff,
ClearCache,
ClearChargingProfile,
ClearDERControl,
ClearDisplayMessage,
ClearTariffs,
ClearVariableMonitoring,
ClearedChargingLimit,
ClosePeriodicEventStream,
CostUpdated,
CustomerInformation,
DataTransfer,
DeleteCertificate,
FirmwareStatusNotification,
Get15118EVCertificate,
GetBaseReport,
GetCertificateChainStatus,
GetCertificateStatus,
GetChargingProfiles,
GetCompositeSchedule,
GetDERControl,
GetDisplayMessages,
GetInstalledCertificateIds,
GetLocalListVersion,
GetLog,
GetMonitoringReport,
GetPeriodicEventStream,
GetReport,
GetTariffs,
GetTransactionStatus,
GetVariables,
Heartbeat,
InstallCertificate,
LogStatusNotification,
MeterValues,
NotifyAllowedEnergyTransfer,
NotifyChargingLimit,
NotifyCustomerInformation,
NotifyDERAlarm,
NotifyDERStartStop,
NotifyDisplayMessages,
NotifyEVChargingNeeds,
NotifyEVChargingSchedule,
NotifyEvent,
NotifyMonitoringReport,
NotifyPeriodicEventStream,
NotifyPriorityCharging,
NotifyReport,
NotifySettlement,
NotifyWebPaymentStarted,
OpenPeriodicEventStream,
PublishFirmware,
PublishFirmwareStatusNotification,
PullDynamicScheduleUpdate,
ReportChargingProfiles,
ReportDERControl,
RequestBatterySwap,
RequestStartTransaction,
RequestStopTransaction,
ReservationStatusUpdate,
ReserveNow,
Reset,
SecurityEventNotification,
SendLocalList,
SetChargingProfile,
SetDERControl,
SetDefaultTariff,
SetDisplayMessage,
SetMonitoringBase,
SetMonitoringLevel,
SetNetworkProfile,
SetVariableMonitoring,
SetVariables,
SignCertificate,
StatusNotification,
TransactionEvent,
TriggerMessage,
UnlockConnector,
UnpublishFirmware,
UpdateDynamicSchedule,
UpdateFirmware,
UsePriorityCharging,
VatNumberValidation,
}
impl Action {
pub const ALL: &'static [Action] = &[
Action::AFRRSignal,
Action::AdjustPeriodicEventStream,
Action::Authorize,
Action::BatterySwap,
Action::BootNotification,
Action::CancelReservation,
Action::CertificateSigned,
Action::ChangeAvailability,
Action::ChangeTransactionTariff,
Action::ClearCache,
Action::ClearChargingProfile,
Action::ClearDERControl,
Action::ClearDisplayMessage,
Action::ClearTariffs,
Action::ClearVariableMonitoring,
Action::ClearedChargingLimit,
Action::ClosePeriodicEventStream,
Action::CostUpdated,
Action::CustomerInformation,
Action::DataTransfer,
Action::DeleteCertificate,
Action::FirmwareStatusNotification,
Action::Get15118EVCertificate,
Action::GetBaseReport,
Action::GetCertificateChainStatus,
Action::GetCertificateStatus,
Action::GetChargingProfiles,
Action::GetCompositeSchedule,
Action::GetDERControl,
Action::GetDisplayMessages,
Action::GetInstalledCertificateIds,
Action::GetLocalListVersion,
Action::GetLog,
Action::GetMonitoringReport,
Action::GetPeriodicEventStream,
Action::GetReport,
Action::GetTariffs,
Action::GetTransactionStatus,
Action::GetVariables,
Action::Heartbeat,
Action::InstallCertificate,
Action::LogStatusNotification,
Action::MeterValues,
Action::NotifyAllowedEnergyTransfer,
Action::NotifyChargingLimit,
Action::NotifyCustomerInformation,
Action::NotifyDERAlarm,
Action::NotifyDERStartStop,
Action::NotifyDisplayMessages,
Action::NotifyEVChargingNeeds,
Action::NotifyEVChargingSchedule,
Action::NotifyEvent,
Action::NotifyMonitoringReport,
Action::NotifyPeriodicEventStream,
Action::NotifyPriorityCharging,
Action::NotifyReport,
Action::NotifySettlement,
Action::NotifyWebPaymentStarted,
Action::OpenPeriodicEventStream,
Action::PublishFirmware,
Action::PublishFirmwareStatusNotification,
Action::PullDynamicScheduleUpdate,
Action::ReportChargingProfiles,
Action::ReportDERControl,
Action::RequestBatterySwap,
Action::RequestStartTransaction,
Action::RequestStopTransaction,
Action::ReservationStatusUpdate,
Action::ReserveNow,
Action::Reset,
Action::SecurityEventNotification,
Action::SendLocalList,
Action::SetChargingProfile,
Action::SetDERControl,
Action::SetDefaultTariff,
Action::SetDisplayMessage,
Action::SetMonitoringBase,
Action::SetMonitoringLevel,
Action::SetNetworkProfile,
Action::SetVariableMonitoring,
Action::SetVariables,
Action::SignCertificate,
Action::StatusNotification,
Action::TransactionEvent,
Action::TriggerMessage,
Action::UnlockConnector,
Action::UnpublishFirmware,
Action::UpdateDynamicSchedule,
Action::UpdateFirmware,
Action::UsePriorityCharging,
Action::VatNumberValidation,
];
pub const fn as_str(&self) -> &'static str {
match self {
Action::AFRRSignal => "AFRRSignal",
Action::AdjustPeriodicEventStream => "AdjustPeriodicEventStream",
Action::Authorize => "Authorize",
Action::BatterySwap => "BatterySwap",
Action::BootNotification => "BootNotification",
Action::CancelReservation => "CancelReservation",
Action::CertificateSigned => "CertificateSigned",
Action::ChangeAvailability => "ChangeAvailability",
Action::ChangeTransactionTariff => "ChangeTransactionTariff",
Action::ClearCache => "ClearCache",
Action::ClearChargingProfile => "ClearChargingProfile",
Action::ClearDERControl => "ClearDERControl",
Action::ClearDisplayMessage => "ClearDisplayMessage",
Action::ClearTariffs => "ClearTariffs",
Action::ClearVariableMonitoring => "ClearVariableMonitoring",
Action::ClearedChargingLimit => "ClearedChargingLimit",
Action::ClosePeriodicEventStream => "ClosePeriodicEventStream",
Action::CostUpdated => "CostUpdated",
Action::CustomerInformation => "CustomerInformation",
Action::DataTransfer => "DataTransfer",
Action::DeleteCertificate => "DeleteCertificate",
Action::FirmwareStatusNotification => "FirmwareStatusNotification",
Action::Get15118EVCertificate => "Get15118EVCertificate",
Action::GetBaseReport => "GetBaseReport",
Action::GetCertificateChainStatus => "GetCertificateChainStatus",
Action::GetCertificateStatus => "GetCertificateStatus",
Action::GetChargingProfiles => "GetChargingProfiles",
Action::GetCompositeSchedule => "GetCompositeSchedule",
Action::GetDERControl => "GetDERControl",
Action::GetDisplayMessages => "GetDisplayMessages",
Action::GetInstalledCertificateIds => "GetInstalledCertificateIds",
Action::GetLocalListVersion => "GetLocalListVersion",
Action::GetLog => "GetLog",
Action::GetMonitoringReport => "GetMonitoringReport",
Action::GetPeriodicEventStream => "GetPeriodicEventStream",
Action::GetReport => "GetReport",
Action::GetTariffs => "GetTariffs",
Action::GetTransactionStatus => "GetTransactionStatus",
Action::GetVariables => "GetVariables",
Action::Heartbeat => "Heartbeat",
Action::InstallCertificate => "InstallCertificate",
Action::LogStatusNotification => "LogStatusNotification",
Action::MeterValues => "MeterValues",
Action::NotifyAllowedEnergyTransfer => "NotifyAllowedEnergyTransfer",
Action::NotifyChargingLimit => "NotifyChargingLimit",
Action::NotifyCustomerInformation => "NotifyCustomerInformation",
Action::NotifyDERAlarm => "NotifyDERAlarm",
Action::NotifyDERStartStop => "NotifyDERStartStop",
Action::NotifyDisplayMessages => "NotifyDisplayMessages",
Action::NotifyEVChargingNeeds => "NotifyEVChargingNeeds",
Action::NotifyEVChargingSchedule => "NotifyEVChargingSchedule",
Action::NotifyEvent => "NotifyEvent",
Action::NotifyMonitoringReport => "NotifyMonitoringReport",
Action::NotifyPeriodicEventStream => "NotifyPeriodicEventStream",
Action::NotifyPriorityCharging => "NotifyPriorityCharging",
Action::NotifyReport => "NotifyReport",
Action::NotifySettlement => "NotifySettlement",
Action::NotifyWebPaymentStarted => "NotifyWebPaymentStarted",
Action::OpenPeriodicEventStream => "OpenPeriodicEventStream",
Action::PublishFirmware => "PublishFirmware",
Action::PublishFirmwareStatusNotification => "PublishFirmwareStatusNotification",
Action::PullDynamicScheduleUpdate => "PullDynamicScheduleUpdate",
Action::ReportChargingProfiles => "ReportChargingProfiles",
Action::ReportDERControl => "ReportDERControl",
Action::RequestBatterySwap => "RequestBatterySwap",
Action::RequestStartTransaction => "RequestStartTransaction",
Action::RequestStopTransaction => "RequestStopTransaction",
Action::ReservationStatusUpdate => "ReservationStatusUpdate",
Action::ReserveNow => "ReserveNow",
Action::Reset => "Reset",
Action::SecurityEventNotification => "SecurityEventNotification",
Action::SendLocalList => "SendLocalList",
Action::SetChargingProfile => "SetChargingProfile",
Action::SetDERControl => "SetDERControl",
Action::SetDefaultTariff => "SetDefaultTariff",
Action::SetDisplayMessage => "SetDisplayMessage",
Action::SetMonitoringBase => "SetMonitoringBase",
Action::SetMonitoringLevel => "SetMonitoringLevel",
Action::SetNetworkProfile => "SetNetworkProfile",
Action::SetVariableMonitoring => "SetVariableMonitoring",
Action::SetVariables => "SetVariables",
Action::SignCertificate => "SignCertificate",
Action::StatusNotification => "StatusNotification",
Action::TransactionEvent => "TransactionEvent",
Action::TriggerMessage => "TriggerMessage",
Action::UnlockConnector => "UnlockConnector",
Action::UnpublishFirmware => "UnpublishFirmware",
Action::UpdateDynamicSchedule => "UpdateDynamicSchedule",
Action::UpdateFirmware => "UpdateFirmware",
Action::UsePriorityCharging => "UsePriorityCharging",
Action::VatNumberValidation => "VatNumberValidation",
}
}
pub fn from_name(s: &str) -> Option<Action> {
match s {
"AFRRSignal" => Some(Action::AFRRSignal),
"AdjustPeriodicEventStream" => Some(Action::AdjustPeriodicEventStream),
"Authorize" => Some(Action::Authorize),
"BatterySwap" => Some(Action::BatterySwap),
"BootNotification" => Some(Action::BootNotification),
"CancelReservation" => Some(Action::CancelReservation),
"CertificateSigned" => Some(Action::CertificateSigned),
"ChangeAvailability" => Some(Action::ChangeAvailability),
"ChangeTransactionTariff" => Some(Action::ChangeTransactionTariff),
"ClearCache" => Some(Action::ClearCache),
"ClearChargingProfile" => Some(Action::ClearChargingProfile),
"ClearDERControl" => Some(Action::ClearDERControl),
"ClearDisplayMessage" => Some(Action::ClearDisplayMessage),
"ClearTariffs" => Some(Action::ClearTariffs),
"ClearVariableMonitoring" => Some(Action::ClearVariableMonitoring),
"ClearedChargingLimit" => Some(Action::ClearedChargingLimit),
"ClosePeriodicEventStream" => Some(Action::ClosePeriodicEventStream),
"CostUpdated" => Some(Action::CostUpdated),
"CustomerInformation" => Some(Action::CustomerInformation),
"DataTransfer" => Some(Action::DataTransfer),
"DeleteCertificate" => Some(Action::DeleteCertificate),
"FirmwareStatusNotification" => Some(Action::FirmwareStatusNotification),
"Get15118EVCertificate" => Some(Action::Get15118EVCertificate),
"GetBaseReport" => Some(Action::GetBaseReport),
"GetCertificateChainStatus" => Some(Action::GetCertificateChainStatus),
"GetCertificateStatus" => Some(Action::GetCertificateStatus),
"GetChargingProfiles" => Some(Action::GetChargingProfiles),
"GetCompositeSchedule" => Some(Action::GetCompositeSchedule),
"GetDERControl" => Some(Action::GetDERControl),
"GetDisplayMessages" => Some(Action::GetDisplayMessages),
"GetInstalledCertificateIds" => Some(Action::GetInstalledCertificateIds),
"GetLocalListVersion" => Some(Action::GetLocalListVersion),
"GetLog" => Some(Action::GetLog),
"GetMonitoringReport" => Some(Action::GetMonitoringReport),
"GetPeriodicEventStream" => Some(Action::GetPeriodicEventStream),
"GetReport" => Some(Action::GetReport),
"GetTariffs" => Some(Action::GetTariffs),
"GetTransactionStatus" => Some(Action::GetTransactionStatus),
"GetVariables" => Some(Action::GetVariables),
"Heartbeat" => Some(Action::Heartbeat),
"InstallCertificate" => Some(Action::InstallCertificate),
"LogStatusNotification" => Some(Action::LogStatusNotification),
"MeterValues" => Some(Action::MeterValues),
"NotifyAllowedEnergyTransfer" => Some(Action::NotifyAllowedEnergyTransfer),
"NotifyChargingLimit" => Some(Action::NotifyChargingLimit),
"NotifyCustomerInformation" => Some(Action::NotifyCustomerInformation),
"NotifyDERAlarm" => Some(Action::NotifyDERAlarm),
"NotifyDERStartStop" => Some(Action::NotifyDERStartStop),
"NotifyDisplayMessages" => Some(Action::NotifyDisplayMessages),
"NotifyEVChargingNeeds" => Some(Action::NotifyEVChargingNeeds),
"NotifyEVChargingSchedule" => Some(Action::NotifyEVChargingSchedule),
"NotifyEvent" => Some(Action::NotifyEvent),
"NotifyMonitoringReport" => Some(Action::NotifyMonitoringReport),
"NotifyPeriodicEventStream" => Some(Action::NotifyPeriodicEventStream),
"NotifyPriorityCharging" => Some(Action::NotifyPriorityCharging),
"NotifyReport" => Some(Action::NotifyReport),
"NotifySettlement" => Some(Action::NotifySettlement),
"NotifyWebPaymentStarted" => Some(Action::NotifyWebPaymentStarted),
"OpenPeriodicEventStream" => Some(Action::OpenPeriodicEventStream),
"PublishFirmware" => Some(Action::PublishFirmware),
"PublishFirmwareStatusNotification" => Some(Action::PublishFirmwareStatusNotification),
"PullDynamicScheduleUpdate" => Some(Action::PullDynamicScheduleUpdate),
"ReportChargingProfiles" => Some(Action::ReportChargingProfiles),
"ReportDERControl" => Some(Action::ReportDERControl),
"RequestBatterySwap" => Some(Action::RequestBatterySwap),
"RequestStartTransaction" => Some(Action::RequestStartTransaction),
"RequestStopTransaction" => Some(Action::RequestStopTransaction),
"ReservationStatusUpdate" => Some(Action::ReservationStatusUpdate),
"ReserveNow" => Some(Action::ReserveNow),
"Reset" => Some(Action::Reset),
"SecurityEventNotification" => Some(Action::SecurityEventNotification),
"SendLocalList" => Some(Action::SendLocalList),
"SetChargingProfile" => Some(Action::SetChargingProfile),
"SetDERControl" => Some(Action::SetDERControl),
"SetDefaultTariff" => Some(Action::SetDefaultTariff),
"SetDisplayMessage" => Some(Action::SetDisplayMessage),
"SetMonitoringBase" => Some(Action::SetMonitoringBase),
"SetMonitoringLevel" => Some(Action::SetMonitoringLevel),
"SetNetworkProfile" => Some(Action::SetNetworkProfile),
"SetVariableMonitoring" => Some(Action::SetVariableMonitoring),
"SetVariables" => Some(Action::SetVariables),
"SignCertificate" => Some(Action::SignCertificate),
"StatusNotification" => Some(Action::StatusNotification),
"TransactionEvent" => Some(Action::TransactionEvent),
"TriggerMessage" => Some(Action::TriggerMessage),
"UnlockConnector" => Some(Action::UnlockConnector),
"UnpublishFirmware" => Some(Action::UnpublishFirmware),
"UpdateDynamicSchedule" => Some(Action::UpdateDynamicSchedule),
"UpdateFirmware" => Some(Action::UpdateFirmware),
"UsePriorityCharging" => Some(Action::UsePriorityCharging),
"VatNumberValidation" => Some(Action::VatNumberValidation),
_ => None,
}
}
pub const fn direction(&self) -> Direction {
match self {
Action::AFRRSignal => Direction::CsmsToStation,
Action::AdjustPeriodicEventStream => Direction::CsmsToStation,
Action::Authorize => Direction::StationToCsms,
Action::BatterySwap => Direction::StationToCsms,
Action::BootNotification => Direction::StationToCsms,
Action::CancelReservation => Direction::CsmsToStation,
Action::CertificateSigned => Direction::CsmsToStation,
Action::ChangeAvailability => Direction::CsmsToStation,
Action::ChangeTransactionTariff => Direction::CsmsToStation,
Action::ClearCache => Direction::CsmsToStation,
Action::ClearChargingProfile => Direction::CsmsToStation,
Action::ClearDERControl => Direction::CsmsToStation,
Action::ClearDisplayMessage => Direction::CsmsToStation,
Action::ClearTariffs => Direction::CsmsToStation,
Action::ClearVariableMonitoring => Direction::CsmsToStation,
Action::ClearedChargingLimit => Direction::StationToCsms,
Action::ClosePeriodicEventStream => Direction::StationToCsms,
Action::CostUpdated => Direction::CsmsToStation,
Action::CustomerInformation => Direction::CsmsToStation,
Action::DataTransfer => Direction::Both,
Action::DeleteCertificate => Direction::CsmsToStation,
Action::FirmwareStatusNotification => Direction::StationToCsms,
Action::Get15118EVCertificate => Direction::StationToCsms,
Action::GetBaseReport => Direction::CsmsToStation,
Action::GetCertificateChainStatus => Direction::StationToCsms,
Action::GetCertificateStatus => Direction::StationToCsms,
Action::GetChargingProfiles => Direction::CsmsToStation,
Action::GetCompositeSchedule => Direction::CsmsToStation,
Action::GetDERControl => Direction::CsmsToStation,
Action::GetDisplayMessages => Direction::CsmsToStation,
Action::GetInstalledCertificateIds => Direction::CsmsToStation,
Action::GetLocalListVersion => Direction::CsmsToStation,
Action::GetLog => Direction::CsmsToStation,
Action::GetMonitoringReport => Direction::CsmsToStation,
Action::GetPeriodicEventStream => Direction::CsmsToStation,
Action::GetReport => Direction::CsmsToStation,
Action::GetTariffs => Direction::CsmsToStation,
Action::GetTransactionStatus => Direction::CsmsToStation,
Action::GetVariables => Direction::CsmsToStation,
Action::Heartbeat => Direction::StationToCsms,
Action::InstallCertificate => Direction::CsmsToStation,
Action::LogStatusNotification => Direction::StationToCsms,
Action::MeterValues => Direction::StationToCsms,
Action::NotifyAllowedEnergyTransfer => Direction::CsmsToStation,
Action::NotifyChargingLimit => Direction::StationToCsms,
Action::NotifyCustomerInformation => Direction::StationToCsms,
Action::NotifyDERAlarm => Direction::StationToCsms,
Action::NotifyDERStartStop => Direction::StationToCsms,
Action::NotifyDisplayMessages => Direction::StationToCsms,
Action::NotifyEVChargingNeeds => Direction::StationToCsms,
Action::NotifyEVChargingSchedule => Direction::StationToCsms,
Action::NotifyEvent => Direction::StationToCsms,
Action::NotifyMonitoringReport => Direction::StationToCsms,
Action::NotifyPeriodicEventStream => Direction::StationToCsms,
Action::NotifyPriorityCharging => Direction::StationToCsms,
Action::NotifyReport => Direction::StationToCsms,
Action::NotifySettlement => Direction::StationToCsms,
Action::NotifyWebPaymentStarted => Direction::CsmsToStation,
Action::OpenPeriodicEventStream => Direction::StationToCsms,
Action::PublishFirmware => Direction::CsmsToStation,
Action::PublishFirmwareStatusNotification => Direction::StationToCsms,
Action::PullDynamicScheduleUpdate => Direction::StationToCsms,
Action::ReportChargingProfiles => Direction::StationToCsms,
Action::ReportDERControl => Direction::StationToCsms,
Action::RequestBatterySwap => Direction::CsmsToStation,
Action::RequestStartTransaction => Direction::CsmsToStation,
Action::RequestStopTransaction => Direction::CsmsToStation,
Action::ReservationStatusUpdate => Direction::StationToCsms,
Action::ReserveNow => Direction::CsmsToStation,
Action::Reset => Direction::CsmsToStation,
Action::SecurityEventNotification => Direction::StationToCsms,
Action::SendLocalList => Direction::CsmsToStation,
Action::SetChargingProfile => Direction::CsmsToStation,
Action::SetDERControl => Direction::CsmsToStation,
Action::SetDefaultTariff => Direction::CsmsToStation,
Action::SetDisplayMessage => Direction::CsmsToStation,
Action::SetMonitoringBase => Direction::CsmsToStation,
Action::SetMonitoringLevel => Direction::CsmsToStation,
Action::SetNetworkProfile => Direction::CsmsToStation,
Action::SetVariableMonitoring => Direction::CsmsToStation,
Action::SetVariables => Direction::CsmsToStation,
Action::SignCertificate => Direction::StationToCsms,
Action::StatusNotification => Direction::StationToCsms,
Action::TransactionEvent => Direction::StationToCsms,
Action::TriggerMessage => Direction::CsmsToStation,
Action::UnlockConnector => Direction::CsmsToStation,
Action::UnpublishFirmware => Direction::CsmsToStation,
Action::UpdateDynamicSchedule => Direction::CsmsToStation,
Action::UpdateFirmware => Direction::CsmsToStation,
Action::UsePriorityCharging => Direction::CsmsToStation,
Action::VatNumberValidation => Direction::StationToCsms,
}
}
pub const fn is_send(&self) -> bool {
matches!(self, Action::NotifyPeriodicEventStream)
}
}
impl std::fmt::Display for Action {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum DecodeError {
UnknownAction(String),
WrongDirection(Action),
Invalid(Violation),
}
impl std::fmt::Display for DecodeError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
DecodeError::UnknownAction(a) => write!(f, "unknown action '{a}'"),
DecodeError::WrongDirection(a) => {
write!(f, "action '{a}' is not accepted in this direction")
}
DecodeError::Invalid(v) => write!(f, "{v}"),
}
}
}
impl std::error::Error for DecodeError {}
#[derive(Debug, Clone, PartialEq)]
pub enum StationCall {
Authorize(AuthorizeRequest),
BatterySwap(BatterySwapRequest),
BootNotification(BootNotificationRequest),
ClearedChargingLimit(ClearedChargingLimitRequest),
ClosePeriodicEventStream(ClosePeriodicEventStreamRequest),
DataTransfer(DataTransferRequest),
FirmwareStatusNotification(FirmwareStatusNotificationRequest),
Get15118EVCertificate(Get15118EVCertificateRequest),
GetCertificateChainStatus(GetCertificateChainStatusRequest),
GetCertificateStatus(GetCertificateStatusRequest),
Heartbeat(HeartbeatRequest),
LogStatusNotification(LogStatusNotificationRequest),
MeterValues(MeterValuesRequest),
NotifyChargingLimit(NotifyChargingLimitRequest),
NotifyCustomerInformation(NotifyCustomerInformationRequest),
NotifyDERAlarm(NotifyDERAlarmRequest),
NotifyDERStartStop(NotifyDERStartStopRequest),
NotifyDisplayMessages(NotifyDisplayMessagesRequest),
NotifyEVChargingNeeds(NotifyEVChargingNeedsRequest),
NotifyEVChargingSchedule(NotifyEVChargingScheduleRequest),
NotifyEvent(NotifyEventRequest),
NotifyMonitoringReport(NotifyMonitoringReportRequest),
NotifyPriorityCharging(NotifyPriorityChargingRequest),
NotifyReport(NotifyReportRequest),
NotifySettlement(NotifySettlementRequest),
OpenPeriodicEventStream(OpenPeriodicEventStreamRequest),
PublishFirmwareStatusNotification(PublishFirmwareStatusNotificationRequest),
PullDynamicScheduleUpdate(PullDynamicScheduleUpdateRequest),
ReportChargingProfiles(ReportChargingProfilesRequest),
ReportDERControl(ReportDERControlRequest),
ReservationStatusUpdate(ReservationStatusUpdateRequest),
SecurityEventNotification(SecurityEventNotificationRequest),
SignCertificate(SignCertificateRequest),
StatusNotification(StatusNotificationRequest),
TransactionEvent(TransactionEventRequest),
VatNumberValidation(VatNumberValidationRequest),
}
impl StationCall {
pub const fn action(&self) -> Action {
match self {
StationCall::Authorize(_) => Action::Authorize,
StationCall::BatterySwap(_) => Action::BatterySwap,
StationCall::BootNotification(_) => Action::BootNotification,
StationCall::ClearedChargingLimit(_) => Action::ClearedChargingLimit,
StationCall::ClosePeriodicEventStream(_) => Action::ClosePeriodicEventStream,
StationCall::DataTransfer(_) => Action::DataTransfer,
StationCall::FirmwareStatusNotification(_) => Action::FirmwareStatusNotification,
StationCall::Get15118EVCertificate(_) => Action::Get15118EVCertificate,
StationCall::GetCertificateChainStatus(_) => Action::GetCertificateChainStatus,
StationCall::GetCertificateStatus(_) => Action::GetCertificateStatus,
StationCall::Heartbeat(_) => Action::Heartbeat,
StationCall::LogStatusNotification(_) => Action::LogStatusNotification,
StationCall::MeterValues(_) => Action::MeterValues,
StationCall::NotifyChargingLimit(_) => Action::NotifyChargingLimit,
StationCall::NotifyCustomerInformation(_) => Action::NotifyCustomerInformation,
StationCall::NotifyDERAlarm(_) => Action::NotifyDERAlarm,
StationCall::NotifyDERStartStop(_) => Action::NotifyDERStartStop,
StationCall::NotifyDisplayMessages(_) => Action::NotifyDisplayMessages,
StationCall::NotifyEVChargingNeeds(_) => Action::NotifyEVChargingNeeds,
StationCall::NotifyEVChargingSchedule(_) => Action::NotifyEVChargingSchedule,
StationCall::NotifyEvent(_) => Action::NotifyEvent,
StationCall::NotifyMonitoringReport(_) => Action::NotifyMonitoringReport,
StationCall::NotifyPriorityCharging(_) => Action::NotifyPriorityCharging,
StationCall::NotifyReport(_) => Action::NotifyReport,
StationCall::NotifySettlement(_) => Action::NotifySettlement,
StationCall::OpenPeriodicEventStream(_) => Action::OpenPeriodicEventStream,
StationCall::PublishFirmwareStatusNotification(_) => {
Action::PublishFirmwareStatusNotification
}
StationCall::PullDynamicScheduleUpdate(_) => Action::PullDynamicScheduleUpdate,
StationCall::ReportChargingProfiles(_) => Action::ReportChargingProfiles,
StationCall::ReportDERControl(_) => Action::ReportDERControl,
StationCall::ReservationStatusUpdate(_) => Action::ReservationStatusUpdate,
StationCall::SecurityEventNotification(_) => Action::SecurityEventNotification,
StationCall::SignCertificate(_) => Action::SignCertificate,
StationCall::StatusNotification(_) => Action::StatusNotification,
StationCall::TransactionEvent(_) => Action::TransactionEvent,
StationCall::VatNumberValidation(_) => Action::VatNumberValidation,
}
}
pub fn decode(action: &str, payload: &str) -> Result<Self, DecodeError> {
let a = Action::from_name(action)
.ok_or_else(|| DecodeError::UnknownAction(action.to_owned()))?;
match a {
Action::Authorize => ocpp_core::decode_payload(payload)
.map(StationCall::Authorize)
.map_err(DecodeError::Invalid),
Action::BatterySwap => ocpp_core::decode_payload(payload)
.map(StationCall::BatterySwap)
.map_err(DecodeError::Invalid),
Action::BootNotification => ocpp_core::decode_payload(payload)
.map(StationCall::BootNotification)
.map_err(DecodeError::Invalid),
Action::ClearedChargingLimit => ocpp_core::decode_payload(payload)
.map(StationCall::ClearedChargingLimit)
.map_err(DecodeError::Invalid),
Action::ClosePeriodicEventStream => ocpp_core::decode_payload(payload)
.map(StationCall::ClosePeriodicEventStream)
.map_err(DecodeError::Invalid),
Action::DataTransfer => ocpp_core::decode_payload(payload)
.map(StationCall::DataTransfer)
.map_err(DecodeError::Invalid),
Action::FirmwareStatusNotification => ocpp_core::decode_payload(payload)
.map(StationCall::FirmwareStatusNotification)
.map_err(DecodeError::Invalid),
Action::Get15118EVCertificate => ocpp_core::decode_payload(payload)
.map(StationCall::Get15118EVCertificate)
.map_err(DecodeError::Invalid),
Action::GetCertificateChainStatus => ocpp_core::decode_payload(payload)
.map(StationCall::GetCertificateChainStatus)
.map_err(DecodeError::Invalid),
Action::GetCertificateStatus => ocpp_core::decode_payload(payload)
.map(StationCall::GetCertificateStatus)
.map_err(DecodeError::Invalid),
Action::Heartbeat => ocpp_core::decode_payload(payload)
.map(StationCall::Heartbeat)
.map_err(DecodeError::Invalid),
Action::LogStatusNotification => ocpp_core::decode_payload(payload)
.map(StationCall::LogStatusNotification)
.map_err(DecodeError::Invalid),
Action::MeterValues => ocpp_core::decode_payload(payload)
.map(StationCall::MeterValues)
.map_err(DecodeError::Invalid),
Action::NotifyChargingLimit => ocpp_core::decode_payload(payload)
.map(StationCall::NotifyChargingLimit)
.map_err(DecodeError::Invalid),
Action::NotifyCustomerInformation => ocpp_core::decode_payload(payload)
.map(StationCall::NotifyCustomerInformation)
.map_err(DecodeError::Invalid),
Action::NotifyDERAlarm => ocpp_core::decode_payload(payload)
.map(StationCall::NotifyDERAlarm)
.map_err(DecodeError::Invalid),
Action::NotifyDERStartStop => ocpp_core::decode_payload(payload)
.map(StationCall::NotifyDERStartStop)
.map_err(DecodeError::Invalid),
Action::NotifyDisplayMessages => ocpp_core::decode_payload(payload)
.map(StationCall::NotifyDisplayMessages)
.map_err(DecodeError::Invalid),
Action::NotifyEVChargingNeeds => ocpp_core::decode_payload(payload)
.map(StationCall::NotifyEVChargingNeeds)
.map_err(DecodeError::Invalid),
Action::NotifyEVChargingSchedule => ocpp_core::decode_payload(payload)
.map(StationCall::NotifyEVChargingSchedule)
.map_err(DecodeError::Invalid),
Action::NotifyEvent => ocpp_core::decode_payload(payload)
.map(StationCall::NotifyEvent)
.map_err(DecodeError::Invalid),
Action::NotifyMonitoringReport => ocpp_core::decode_payload(payload)
.map(StationCall::NotifyMonitoringReport)
.map_err(DecodeError::Invalid),
Action::NotifyPriorityCharging => ocpp_core::decode_payload(payload)
.map(StationCall::NotifyPriorityCharging)
.map_err(DecodeError::Invalid),
Action::NotifyReport => ocpp_core::decode_payload(payload)
.map(StationCall::NotifyReport)
.map_err(DecodeError::Invalid),
Action::NotifySettlement => ocpp_core::decode_payload(payload)
.map(StationCall::NotifySettlement)
.map_err(DecodeError::Invalid),
Action::OpenPeriodicEventStream => ocpp_core::decode_payload(payload)
.map(StationCall::OpenPeriodicEventStream)
.map_err(DecodeError::Invalid),
Action::PublishFirmwareStatusNotification => ocpp_core::decode_payload(payload)
.map(StationCall::PublishFirmwareStatusNotification)
.map_err(DecodeError::Invalid),
Action::PullDynamicScheduleUpdate => ocpp_core::decode_payload(payload)
.map(StationCall::PullDynamicScheduleUpdate)
.map_err(DecodeError::Invalid),
Action::ReportChargingProfiles => ocpp_core::decode_payload(payload)
.map(StationCall::ReportChargingProfiles)
.map_err(DecodeError::Invalid),
Action::ReportDERControl => ocpp_core::decode_payload(payload)
.map(StationCall::ReportDERControl)
.map_err(DecodeError::Invalid),
Action::ReservationStatusUpdate => ocpp_core::decode_payload(payload)
.map(StationCall::ReservationStatusUpdate)
.map_err(DecodeError::Invalid),
Action::SecurityEventNotification => ocpp_core::decode_payload(payload)
.map(StationCall::SecurityEventNotification)
.map_err(DecodeError::Invalid),
Action::SignCertificate => ocpp_core::decode_payload(payload)
.map(StationCall::SignCertificate)
.map_err(DecodeError::Invalid),
Action::StatusNotification => ocpp_core::decode_payload(payload)
.map(StationCall::StatusNotification)
.map_err(DecodeError::Invalid),
Action::TransactionEvent => ocpp_core::decode_payload(payload)
.map(StationCall::TransactionEvent)
.map_err(DecodeError::Invalid),
Action::VatNumberValidation => ocpp_core::decode_payload(payload)
.map(StationCall::VatNumberValidation)
.map_err(DecodeError::Invalid),
#[allow(unreachable_patterns)]
other => Err(DecodeError::WrongDirection(other)),
}
}
pub fn from_value(action: &str, payload: serde_json::Value) -> Result<Self, DecodeError> {
let a = Action::from_name(action)
.ok_or_else(|| DecodeError::UnknownAction(action.to_owned()))?;
match a {
Action::Authorize => ocpp_core::decode_value(payload)
.map(StationCall::Authorize)
.map_err(DecodeError::Invalid),
Action::BatterySwap => ocpp_core::decode_value(payload)
.map(StationCall::BatterySwap)
.map_err(DecodeError::Invalid),
Action::BootNotification => ocpp_core::decode_value(payload)
.map(StationCall::BootNotification)
.map_err(DecodeError::Invalid),
Action::ClearedChargingLimit => ocpp_core::decode_value(payload)
.map(StationCall::ClearedChargingLimit)
.map_err(DecodeError::Invalid),
Action::ClosePeriodicEventStream => ocpp_core::decode_value(payload)
.map(StationCall::ClosePeriodicEventStream)
.map_err(DecodeError::Invalid),
Action::DataTransfer => ocpp_core::decode_value(payload)
.map(StationCall::DataTransfer)
.map_err(DecodeError::Invalid),
Action::FirmwareStatusNotification => ocpp_core::decode_value(payload)
.map(StationCall::FirmwareStatusNotification)
.map_err(DecodeError::Invalid),
Action::Get15118EVCertificate => ocpp_core::decode_value(payload)
.map(StationCall::Get15118EVCertificate)
.map_err(DecodeError::Invalid),
Action::GetCertificateChainStatus => ocpp_core::decode_value(payload)
.map(StationCall::GetCertificateChainStatus)
.map_err(DecodeError::Invalid),
Action::GetCertificateStatus => ocpp_core::decode_value(payload)
.map(StationCall::GetCertificateStatus)
.map_err(DecodeError::Invalid),
Action::Heartbeat => ocpp_core::decode_value(payload)
.map(StationCall::Heartbeat)
.map_err(DecodeError::Invalid),
Action::LogStatusNotification => ocpp_core::decode_value(payload)
.map(StationCall::LogStatusNotification)
.map_err(DecodeError::Invalid),
Action::MeterValues => ocpp_core::decode_value(payload)
.map(StationCall::MeterValues)
.map_err(DecodeError::Invalid),
Action::NotifyChargingLimit => ocpp_core::decode_value(payload)
.map(StationCall::NotifyChargingLimit)
.map_err(DecodeError::Invalid),
Action::NotifyCustomerInformation => ocpp_core::decode_value(payload)
.map(StationCall::NotifyCustomerInformation)
.map_err(DecodeError::Invalid),
Action::NotifyDERAlarm => ocpp_core::decode_value(payload)
.map(StationCall::NotifyDERAlarm)
.map_err(DecodeError::Invalid),
Action::NotifyDERStartStop => ocpp_core::decode_value(payload)
.map(StationCall::NotifyDERStartStop)
.map_err(DecodeError::Invalid),
Action::NotifyDisplayMessages => ocpp_core::decode_value(payload)
.map(StationCall::NotifyDisplayMessages)
.map_err(DecodeError::Invalid),
Action::NotifyEVChargingNeeds => ocpp_core::decode_value(payload)
.map(StationCall::NotifyEVChargingNeeds)
.map_err(DecodeError::Invalid),
Action::NotifyEVChargingSchedule => ocpp_core::decode_value(payload)
.map(StationCall::NotifyEVChargingSchedule)
.map_err(DecodeError::Invalid),
Action::NotifyEvent => ocpp_core::decode_value(payload)
.map(StationCall::NotifyEvent)
.map_err(DecodeError::Invalid),
Action::NotifyMonitoringReport => ocpp_core::decode_value(payload)
.map(StationCall::NotifyMonitoringReport)
.map_err(DecodeError::Invalid),
Action::NotifyPriorityCharging => ocpp_core::decode_value(payload)
.map(StationCall::NotifyPriorityCharging)
.map_err(DecodeError::Invalid),
Action::NotifyReport => ocpp_core::decode_value(payload)
.map(StationCall::NotifyReport)
.map_err(DecodeError::Invalid),
Action::NotifySettlement => ocpp_core::decode_value(payload)
.map(StationCall::NotifySettlement)
.map_err(DecodeError::Invalid),
Action::OpenPeriodicEventStream => ocpp_core::decode_value(payload)
.map(StationCall::OpenPeriodicEventStream)
.map_err(DecodeError::Invalid),
Action::PublishFirmwareStatusNotification => ocpp_core::decode_value(payload)
.map(StationCall::PublishFirmwareStatusNotification)
.map_err(DecodeError::Invalid),
Action::PullDynamicScheduleUpdate => ocpp_core::decode_value(payload)
.map(StationCall::PullDynamicScheduleUpdate)
.map_err(DecodeError::Invalid),
Action::ReportChargingProfiles => ocpp_core::decode_value(payload)
.map(StationCall::ReportChargingProfiles)
.map_err(DecodeError::Invalid),
Action::ReportDERControl => ocpp_core::decode_value(payload)
.map(StationCall::ReportDERControl)
.map_err(DecodeError::Invalid),
Action::ReservationStatusUpdate => ocpp_core::decode_value(payload)
.map(StationCall::ReservationStatusUpdate)
.map_err(DecodeError::Invalid),
Action::SecurityEventNotification => ocpp_core::decode_value(payload)
.map(StationCall::SecurityEventNotification)
.map_err(DecodeError::Invalid),
Action::SignCertificate => ocpp_core::decode_value(payload)
.map(StationCall::SignCertificate)
.map_err(DecodeError::Invalid),
Action::StatusNotification => ocpp_core::decode_value(payload)
.map(StationCall::StatusNotification)
.map_err(DecodeError::Invalid),
Action::TransactionEvent => ocpp_core::decode_value(payload)
.map(StationCall::TransactionEvent)
.map_err(DecodeError::Invalid),
Action::VatNumberValidation => ocpp_core::decode_value(payload)
.map(StationCall::VatNumberValidation)
.map_err(DecodeError::Invalid),
#[allow(unreachable_patterns)]
other => Err(DecodeError::WrongDirection(other)),
}
}
pub fn to_payload(&self) -> serde_json::Value {
match self {
StationCall::Authorize(r) => serde_json::to_value(r).expect("serializable"),
StationCall::BatterySwap(r) => serde_json::to_value(r).expect("serializable"),
StationCall::BootNotification(r) => serde_json::to_value(r).expect("serializable"),
StationCall::ClearedChargingLimit(r) => serde_json::to_value(r).expect("serializable"),
StationCall::ClosePeriodicEventStream(r) => {
serde_json::to_value(r).expect("serializable")
}
StationCall::DataTransfer(r) => serde_json::to_value(r).expect("serializable"),
StationCall::FirmwareStatusNotification(r) => {
serde_json::to_value(r).expect("serializable")
}
StationCall::Get15118EVCertificate(r) => serde_json::to_value(r).expect("serializable"),
StationCall::GetCertificateChainStatus(r) => {
serde_json::to_value(r).expect("serializable")
}
StationCall::GetCertificateStatus(r) => serde_json::to_value(r).expect("serializable"),
StationCall::Heartbeat(r) => serde_json::to_value(r).expect("serializable"),
StationCall::LogStatusNotification(r) => serde_json::to_value(r).expect("serializable"),
StationCall::MeterValues(r) => serde_json::to_value(r).expect("serializable"),
StationCall::NotifyChargingLimit(r) => serde_json::to_value(r).expect("serializable"),
StationCall::NotifyCustomerInformation(r) => {
serde_json::to_value(r).expect("serializable")
}
StationCall::NotifyDERAlarm(r) => serde_json::to_value(r).expect("serializable"),
StationCall::NotifyDERStartStop(r) => serde_json::to_value(r).expect("serializable"),
StationCall::NotifyDisplayMessages(r) => serde_json::to_value(r).expect("serializable"),
StationCall::NotifyEVChargingNeeds(r) => serde_json::to_value(r).expect("serializable"),
StationCall::NotifyEVChargingSchedule(r) => {
serde_json::to_value(r).expect("serializable")
}
StationCall::NotifyEvent(r) => serde_json::to_value(r).expect("serializable"),
StationCall::NotifyMonitoringReport(r) => {
serde_json::to_value(r).expect("serializable")
}
StationCall::NotifyPriorityCharging(r) => {
serde_json::to_value(r).expect("serializable")
}
StationCall::NotifyReport(r) => serde_json::to_value(r).expect("serializable"),
StationCall::NotifySettlement(r) => serde_json::to_value(r).expect("serializable"),
StationCall::OpenPeriodicEventStream(r) => {
serde_json::to_value(r).expect("serializable")
}
StationCall::PublishFirmwareStatusNotification(r) => {
serde_json::to_value(r).expect("serializable")
}
StationCall::PullDynamicScheduleUpdate(r) => {
serde_json::to_value(r).expect("serializable")
}
StationCall::ReportChargingProfiles(r) => {
serde_json::to_value(r).expect("serializable")
}
StationCall::ReportDERControl(r) => serde_json::to_value(r).expect("serializable"),
StationCall::ReservationStatusUpdate(r) => {
serde_json::to_value(r).expect("serializable")
}
StationCall::SecurityEventNotification(r) => {
serde_json::to_value(r).expect("serializable")
}
StationCall::SignCertificate(r) => serde_json::to_value(r).expect("serializable"),
StationCall::StatusNotification(r) => serde_json::to_value(r).expect("serializable"),
StationCall::TransactionEvent(r) => serde_json::to_value(r).expect("serializable"),
StationCall::VatNumberValidation(r) => serde_json::to_value(r).expect("serializable"),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum CsmsCall {
AFRRSignal(AFRRSignalRequest),
AdjustPeriodicEventStream(AdjustPeriodicEventStreamRequest),
CancelReservation(CancelReservationRequest),
CertificateSigned(CertificateSignedRequest),
ChangeAvailability(ChangeAvailabilityRequest),
ChangeTransactionTariff(ChangeTransactionTariffRequest),
ClearCache(ClearCacheRequest),
ClearChargingProfile(ClearChargingProfileRequest),
ClearDERControl(ClearDERControlRequest),
ClearDisplayMessage(ClearDisplayMessageRequest),
ClearTariffs(ClearTariffsRequest),
ClearVariableMonitoring(ClearVariableMonitoringRequest),
CostUpdated(CostUpdatedRequest),
CustomerInformation(CustomerInformationRequest),
DataTransfer(DataTransferRequest),
DeleteCertificate(DeleteCertificateRequest),
GetBaseReport(GetBaseReportRequest),
GetChargingProfiles(GetChargingProfilesRequest),
GetCompositeSchedule(GetCompositeScheduleRequest),
GetDERControl(GetDERControlRequest),
GetDisplayMessages(GetDisplayMessagesRequest),
GetInstalledCertificateIds(GetInstalledCertificateIdsRequest),
GetLocalListVersion(GetLocalListVersionRequest),
GetLog(GetLogRequest),
GetMonitoringReport(GetMonitoringReportRequest),
GetPeriodicEventStream(GetPeriodicEventStreamRequest),
GetReport(GetReportRequest),
GetTariffs(GetTariffsRequest),
GetTransactionStatus(GetTransactionStatusRequest),
GetVariables(GetVariablesRequest),
InstallCertificate(InstallCertificateRequest),
NotifyAllowedEnergyTransfer(NotifyAllowedEnergyTransferRequest),
NotifyWebPaymentStarted(NotifyWebPaymentStartedRequest),
PublishFirmware(PublishFirmwareRequest),
RequestBatterySwap(RequestBatterySwapRequest),
RequestStartTransaction(RequestStartTransactionRequest),
RequestStopTransaction(RequestStopTransactionRequest),
ReserveNow(ReserveNowRequest),
Reset(ResetRequest),
SendLocalList(SendLocalListRequest),
SetChargingProfile(SetChargingProfileRequest),
SetDERControl(SetDERControlRequest),
SetDefaultTariff(SetDefaultTariffRequest),
SetDisplayMessage(SetDisplayMessageRequest),
SetMonitoringBase(SetMonitoringBaseRequest),
SetMonitoringLevel(SetMonitoringLevelRequest),
SetNetworkProfile(SetNetworkProfileRequest),
SetVariableMonitoring(SetVariableMonitoringRequest),
SetVariables(SetVariablesRequest),
TriggerMessage(TriggerMessageRequest),
UnlockConnector(UnlockConnectorRequest),
UnpublishFirmware(UnpublishFirmwareRequest),
UpdateDynamicSchedule(UpdateDynamicScheduleRequest),
UpdateFirmware(UpdateFirmwareRequest),
UsePriorityCharging(UsePriorityChargingRequest),
}
impl CsmsCall {
pub const fn action(&self) -> Action {
match self {
CsmsCall::AFRRSignal(_) => Action::AFRRSignal,
CsmsCall::AdjustPeriodicEventStream(_) => Action::AdjustPeriodicEventStream,
CsmsCall::CancelReservation(_) => Action::CancelReservation,
CsmsCall::CertificateSigned(_) => Action::CertificateSigned,
CsmsCall::ChangeAvailability(_) => Action::ChangeAvailability,
CsmsCall::ChangeTransactionTariff(_) => Action::ChangeTransactionTariff,
CsmsCall::ClearCache(_) => Action::ClearCache,
CsmsCall::ClearChargingProfile(_) => Action::ClearChargingProfile,
CsmsCall::ClearDERControl(_) => Action::ClearDERControl,
CsmsCall::ClearDisplayMessage(_) => Action::ClearDisplayMessage,
CsmsCall::ClearTariffs(_) => Action::ClearTariffs,
CsmsCall::ClearVariableMonitoring(_) => Action::ClearVariableMonitoring,
CsmsCall::CostUpdated(_) => Action::CostUpdated,
CsmsCall::CustomerInformation(_) => Action::CustomerInformation,
CsmsCall::DataTransfer(_) => Action::DataTransfer,
CsmsCall::DeleteCertificate(_) => Action::DeleteCertificate,
CsmsCall::GetBaseReport(_) => Action::GetBaseReport,
CsmsCall::GetChargingProfiles(_) => Action::GetChargingProfiles,
CsmsCall::GetCompositeSchedule(_) => Action::GetCompositeSchedule,
CsmsCall::GetDERControl(_) => Action::GetDERControl,
CsmsCall::GetDisplayMessages(_) => Action::GetDisplayMessages,
CsmsCall::GetInstalledCertificateIds(_) => Action::GetInstalledCertificateIds,
CsmsCall::GetLocalListVersion(_) => Action::GetLocalListVersion,
CsmsCall::GetLog(_) => Action::GetLog,
CsmsCall::GetMonitoringReport(_) => Action::GetMonitoringReport,
CsmsCall::GetPeriodicEventStream(_) => Action::GetPeriodicEventStream,
CsmsCall::GetReport(_) => Action::GetReport,
CsmsCall::GetTariffs(_) => Action::GetTariffs,
CsmsCall::GetTransactionStatus(_) => Action::GetTransactionStatus,
CsmsCall::GetVariables(_) => Action::GetVariables,
CsmsCall::InstallCertificate(_) => Action::InstallCertificate,
CsmsCall::NotifyAllowedEnergyTransfer(_) => Action::NotifyAllowedEnergyTransfer,
CsmsCall::NotifyWebPaymentStarted(_) => Action::NotifyWebPaymentStarted,
CsmsCall::PublishFirmware(_) => Action::PublishFirmware,
CsmsCall::RequestBatterySwap(_) => Action::RequestBatterySwap,
CsmsCall::RequestStartTransaction(_) => Action::RequestStartTransaction,
CsmsCall::RequestStopTransaction(_) => Action::RequestStopTransaction,
CsmsCall::ReserveNow(_) => Action::ReserveNow,
CsmsCall::Reset(_) => Action::Reset,
CsmsCall::SendLocalList(_) => Action::SendLocalList,
CsmsCall::SetChargingProfile(_) => Action::SetChargingProfile,
CsmsCall::SetDERControl(_) => Action::SetDERControl,
CsmsCall::SetDefaultTariff(_) => Action::SetDefaultTariff,
CsmsCall::SetDisplayMessage(_) => Action::SetDisplayMessage,
CsmsCall::SetMonitoringBase(_) => Action::SetMonitoringBase,
CsmsCall::SetMonitoringLevel(_) => Action::SetMonitoringLevel,
CsmsCall::SetNetworkProfile(_) => Action::SetNetworkProfile,
CsmsCall::SetVariableMonitoring(_) => Action::SetVariableMonitoring,
CsmsCall::SetVariables(_) => Action::SetVariables,
CsmsCall::TriggerMessage(_) => Action::TriggerMessage,
CsmsCall::UnlockConnector(_) => Action::UnlockConnector,
CsmsCall::UnpublishFirmware(_) => Action::UnpublishFirmware,
CsmsCall::UpdateDynamicSchedule(_) => Action::UpdateDynamicSchedule,
CsmsCall::UpdateFirmware(_) => Action::UpdateFirmware,
CsmsCall::UsePriorityCharging(_) => Action::UsePriorityCharging,
}
}
pub fn decode(action: &str, payload: &str) -> Result<Self, DecodeError> {
let a = Action::from_name(action)
.ok_or_else(|| DecodeError::UnknownAction(action.to_owned()))?;
match a {
Action::AFRRSignal => ocpp_core::decode_payload(payload)
.map(CsmsCall::AFRRSignal)
.map_err(DecodeError::Invalid),
Action::AdjustPeriodicEventStream => ocpp_core::decode_payload(payload)
.map(CsmsCall::AdjustPeriodicEventStream)
.map_err(DecodeError::Invalid),
Action::CancelReservation => ocpp_core::decode_payload(payload)
.map(CsmsCall::CancelReservation)
.map_err(DecodeError::Invalid),
Action::CertificateSigned => ocpp_core::decode_payload(payload)
.map(CsmsCall::CertificateSigned)
.map_err(DecodeError::Invalid),
Action::ChangeAvailability => ocpp_core::decode_payload(payload)
.map(CsmsCall::ChangeAvailability)
.map_err(DecodeError::Invalid),
Action::ChangeTransactionTariff => ocpp_core::decode_payload(payload)
.map(CsmsCall::ChangeTransactionTariff)
.map_err(DecodeError::Invalid),
Action::ClearCache => ocpp_core::decode_payload(payload)
.map(CsmsCall::ClearCache)
.map_err(DecodeError::Invalid),
Action::ClearChargingProfile => ocpp_core::decode_payload(payload)
.map(CsmsCall::ClearChargingProfile)
.map_err(DecodeError::Invalid),
Action::ClearDERControl => ocpp_core::decode_payload(payload)
.map(CsmsCall::ClearDERControl)
.map_err(DecodeError::Invalid),
Action::ClearDisplayMessage => ocpp_core::decode_payload(payload)
.map(CsmsCall::ClearDisplayMessage)
.map_err(DecodeError::Invalid),
Action::ClearTariffs => ocpp_core::decode_payload(payload)
.map(CsmsCall::ClearTariffs)
.map_err(DecodeError::Invalid),
Action::ClearVariableMonitoring => ocpp_core::decode_payload(payload)
.map(CsmsCall::ClearVariableMonitoring)
.map_err(DecodeError::Invalid),
Action::CostUpdated => ocpp_core::decode_payload(payload)
.map(CsmsCall::CostUpdated)
.map_err(DecodeError::Invalid),
Action::CustomerInformation => ocpp_core::decode_payload(payload)
.map(CsmsCall::CustomerInformation)
.map_err(DecodeError::Invalid),
Action::DataTransfer => ocpp_core::decode_payload(payload)
.map(CsmsCall::DataTransfer)
.map_err(DecodeError::Invalid),
Action::DeleteCertificate => ocpp_core::decode_payload(payload)
.map(CsmsCall::DeleteCertificate)
.map_err(DecodeError::Invalid),
Action::GetBaseReport => ocpp_core::decode_payload(payload)
.map(CsmsCall::GetBaseReport)
.map_err(DecodeError::Invalid),
Action::GetChargingProfiles => ocpp_core::decode_payload(payload)
.map(CsmsCall::GetChargingProfiles)
.map_err(DecodeError::Invalid),
Action::GetCompositeSchedule => ocpp_core::decode_payload(payload)
.map(CsmsCall::GetCompositeSchedule)
.map_err(DecodeError::Invalid),
Action::GetDERControl => ocpp_core::decode_payload(payload)
.map(CsmsCall::GetDERControl)
.map_err(DecodeError::Invalid),
Action::GetDisplayMessages => ocpp_core::decode_payload(payload)
.map(CsmsCall::GetDisplayMessages)
.map_err(DecodeError::Invalid),
Action::GetInstalledCertificateIds => ocpp_core::decode_payload(payload)
.map(CsmsCall::GetInstalledCertificateIds)
.map_err(DecodeError::Invalid),
Action::GetLocalListVersion => ocpp_core::decode_payload(payload)
.map(CsmsCall::GetLocalListVersion)
.map_err(DecodeError::Invalid),
Action::GetLog => ocpp_core::decode_payload(payload)
.map(CsmsCall::GetLog)
.map_err(DecodeError::Invalid),
Action::GetMonitoringReport => ocpp_core::decode_payload(payload)
.map(CsmsCall::GetMonitoringReport)
.map_err(DecodeError::Invalid),
Action::GetPeriodicEventStream => ocpp_core::decode_payload(payload)
.map(CsmsCall::GetPeriodicEventStream)
.map_err(DecodeError::Invalid),
Action::GetReport => ocpp_core::decode_payload(payload)
.map(CsmsCall::GetReport)
.map_err(DecodeError::Invalid),
Action::GetTariffs => ocpp_core::decode_payload(payload)
.map(CsmsCall::GetTariffs)
.map_err(DecodeError::Invalid),
Action::GetTransactionStatus => ocpp_core::decode_payload(payload)
.map(CsmsCall::GetTransactionStatus)
.map_err(DecodeError::Invalid),
Action::GetVariables => ocpp_core::decode_payload(payload)
.map(CsmsCall::GetVariables)
.map_err(DecodeError::Invalid),
Action::InstallCertificate => ocpp_core::decode_payload(payload)
.map(CsmsCall::InstallCertificate)
.map_err(DecodeError::Invalid),
Action::NotifyAllowedEnergyTransfer => ocpp_core::decode_payload(payload)
.map(CsmsCall::NotifyAllowedEnergyTransfer)
.map_err(DecodeError::Invalid),
Action::NotifyWebPaymentStarted => ocpp_core::decode_payload(payload)
.map(CsmsCall::NotifyWebPaymentStarted)
.map_err(DecodeError::Invalid),
Action::PublishFirmware => ocpp_core::decode_payload(payload)
.map(CsmsCall::PublishFirmware)
.map_err(DecodeError::Invalid),
Action::RequestBatterySwap => ocpp_core::decode_payload(payload)
.map(CsmsCall::RequestBatterySwap)
.map_err(DecodeError::Invalid),
Action::RequestStartTransaction => ocpp_core::decode_payload(payload)
.map(CsmsCall::RequestStartTransaction)
.map_err(DecodeError::Invalid),
Action::RequestStopTransaction => ocpp_core::decode_payload(payload)
.map(CsmsCall::RequestStopTransaction)
.map_err(DecodeError::Invalid),
Action::ReserveNow => ocpp_core::decode_payload(payload)
.map(CsmsCall::ReserveNow)
.map_err(DecodeError::Invalid),
Action::Reset => ocpp_core::decode_payload(payload)
.map(CsmsCall::Reset)
.map_err(DecodeError::Invalid),
Action::SendLocalList => ocpp_core::decode_payload(payload)
.map(CsmsCall::SendLocalList)
.map_err(DecodeError::Invalid),
Action::SetChargingProfile => ocpp_core::decode_payload(payload)
.map(CsmsCall::SetChargingProfile)
.map_err(DecodeError::Invalid),
Action::SetDERControl => ocpp_core::decode_payload(payload)
.map(CsmsCall::SetDERControl)
.map_err(DecodeError::Invalid),
Action::SetDefaultTariff => ocpp_core::decode_payload(payload)
.map(CsmsCall::SetDefaultTariff)
.map_err(DecodeError::Invalid),
Action::SetDisplayMessage => ocpp_core::decode_payload(payload)
.map(CsmsCall::SetDisplayMessage)
.map_err(DecodeError::Invalid),
Action::SetMonitoringBase => ocpp_core::decode_payload(payload)
.map(CsmsCall::SetMonitoringBase)
.map_err(DecodeError::Invalid),
Action::SetMonitoringLevel => ocpp_core::decode_payload(payload)
.map(CsmsCall::SetMonitoringLevel)
.map_err(DecodeError::Invalid),
Action::SetNetworkProfile => ocpp_core::decode_payload(payload)
.map(CsmsCall::SetNetworkProfile)
.map_err(DecodeError::Invalid),
Action::SetVariableMonitoring => ocpp_core::decode_payload(payload)
.map(CsmsCall::SetVariableMonitoring)
.map_err(DecodeError::Invalid),
Action::SetVariables => ocpp_core::decode_payload(payload)
.map(CsmsCall::SetVariables)
.map_err(DecodeError::Invalid),
Action::TriggerMessage => ocpp_core::decode_payload(payload)
.map(CsmsCall::TriggerMessage)
.map_err(DecodeError::Invalid),
Action::UnlockConnector => ocpp_core::decode_payload(payload)
.map(CsmsCall::UnlockConnector)
.map_err(DecodeError::Invalid),
Action::UnpublishFirmware => ocpp_core::decode_payload(payload)
.map(CsmsCall::UnpublishFirmware)
.map_err(DecodeError::Invalid),
Action::UpdateDynamicSchedule => ocpp_core::decode_payload(payload)
.map(CsmsCall::UpdateDynamicSchedule)
.map_err(DecodeError::Invalid),
Action::UpdateFirmware => ocpp_core::decode_payload(payload)
.map(CsmsCall::UpdateFirmware)
.map_err(DecodeError::Invalid),
Action::UsePriorityCharging => ocpp_core::decode_payload(payload)
.map(CsmsCall::UsePriorityCharging)
.map_err(DecodeError::Invalid),
#[allow(unreachable_patterns)]
other => Err(DecodeError::WrongDirection(other)),
}
}
pub fn from_value(action: &str, payload: serde_json::Value) -> Result<Self, DecodeError> {
let a = Action::from_name(action)
.ok_or_else(|| DecodeError::UnknownAction(action.to_owned()))?;
match a {
Action::AFRRSignal => ocpp_core::decode_value(payload)
.map(CsmsCall::AFRRSignal)
.map_err(DecodeError::Invalid),
Action::AdjustPeriodicEventStream => ocpp_core::decode_value(payload)
.map(CsmsCall::AdjustPeriodicEventStream)
.map_err(DecodeError::Invalid),
Action::CancelReservation => ocpp_core::decode_value(payload)
.map(CsmsCall::CancelReservation)
.map_err(DecodeError::Invalid),
Action::CertificateSigned => ocpp_core::decode_value(payload)
.map(CsmsCall::CertificateSigned)
.map_err(DecodeError::Invalid),
Action::ChangeAvailability => ocpp_core::decode_value(payload)
.map(CsmsCall::ChangeAvailability)
.map_err(DecodeError::Invalid),
Action::ChangeTransactionTariff => ocpp_core::decode_value(payload)
.map(CsmsCall::ChangeTransactionTariff)
.map_err(DecodeError::Invalid),
Action::ClearCache => ocpp_core::decode_value(payload)
.map(CsmsCall::ClearCache)
.map_err(DecodeError::Invalid),
Action::ClearChargingProfile => ocpp_core::decode_value(payload)
.map(CsmsCall::ClearChargingProfile)
.map_err(DecodeError::Invalid),
Action::ClearDERControl => ocpp_core::decode_value(payload)
.map(CsmsCall::ClearDERControl)
.map_err(DecodeError::Invalid),
Action::ClearDisplayMessage => ocpp_core::decode_value(payload)
.map(CsmsCall::ClearDisplayMessage)
.map_err(DecodeError::Invalid),
Action::ClearTariffs => ocpp_core::decode_value(payload)
.map(CsmsCall::ClearTariffs)
.map_err(DecodeError::Invalid),
Action::ClearVariableMonitoring => ocpp_core::decode_value(payload)
.map(CsmsCall::ClearVariableMonitoring)
.map_err(DecodeError::Invalid),
Action::CostUpdated => ocpp_core::decode_value(payload)
.map(CsmsCall::CostUpdated)
.map_err(DecodeError::Invalid),
Action::CustomerInformation => ocpp_core::decode_value(payload)
.map(CsmsCall::CustomerInformation)
.map_err(DecodeError::Invalid),
Action::DataTransfer => ocpp_core::decode_value(payload)
.map(CsmsCall::DataTransfer)
.map_err(DecodeError::Invalid),
Action::DeleteCertificate => ocpp_core::decode_value(payload)
.map(CsmsCall::DeleteCertificate)
.map_err(DecodeError::Invalid),
Action::GetBaseReport => ocpp_core::decode_value(payload)
.map(CsmsCall::GetBaseReport)
.map_err(DecodeError::Invalid),
Action::GetChargingProfiles => ocpp_core::decode_value(payload)
.map(CsmsCall::GetChargingProfiles)
.map_err(DecodeError::Invalid),
Action::GetCompositeSchedule => ocpp_core::decode_value(payload)
.map(CsmsCall::GetCompositeSchedule)
.map_err(DecodeError::Invalid),
Action::GetDERControl => ocpp_core::decode_value(payload)
.map(CsmsCall::GetDERControl)
.map_err(DecodeError::Invalid),
Action::GetDisplayMessages => ocpp_core::decode_value(payload)
.map(CsmsCall::GetDisplayMessages)
.map_err(DecodeError::Invalid),
Action::GetInstalledCertificateIds => ocpp_core::decode_value(payload)
.map(CsmsCall::GetInstalledCertificateIds)
.map_err(DecodeError::Invalid),
Action::GetLocalListVersion => ocpp_core::decode_value(payload)
.map(CsmsCall::GetLocalListVersion)
.map_err(DecodeError::Invalid),
Action::GetLog => ocpp_core::decode_value(payload)
.map(CsmsCall::GetLog)
.map_err(DecodeError::Invalid),
Action::GetMonitoringReport => ocpp_core::decode_value(payload)
.map(CsmsCall::GetMonitoringReport)
.map_err(DecodeError::Invalid),
Action::GetPeriodicEventStream => ocpp_core::decode_value(payload)
.map(CsmsCall::GetPeriodicEventStream)
.map_err(DecodeError::Invalid),
Action::GetReport => ocpp_core::decode_value(payload)
.map(CsmsCall::GetReport)
.map_err(DecodeError::Invalid),
Action::GetTariffs => ocpp_core::decode_value(payload)
.map(CsmsCall::GetTariffs)
.map_err(DecodeError::Invalid),
Action::GetTransactionStatus => ocpp_core::decode_value(payload)
.map(CsmsCall::GetTransactionStatus)
.map_err(DecodeError::Invalid),
Action::GetVariables => ocpp_core::decode_value(payload)
.map(CsmsCall::GetVariables)
.map_err(DecodeError::Invalid),
Action::InstallCertificate => ocpp_core::decode_value(payload)
.map(CsmsCall::InstallCertificate)
.map_err(DecodeError::Invalid),
Action::NotifyAllowedEnergyTransfer => ocpp_core::decode_value(payload)
.map(CsmsCall::NotifyAllowedEnergyTransfer)
.map_err(DecodeError::Invalid),
Action::NotifyWebPaymentStarted => ocpp_core::decode_value(payload)
.map(CsmsCall::NotifyWebPaymentStarted)
.map_err(DecodeError::Invalid),
Action::PublishFirmware => ocpp_core::decode_value(payload)
.map(CsmsCall::PublishFirmware)
.map_err(DecodeError::Invalid),
Action::RequestBatterySwap => ocpp_core::decode_value(payload)
.map(CsmsCall::RequestBatterySwap)
.map_err(DecodeError::Invalid),
Action::RequestStartTransaction => ocpp_core::decode_value(payload)
.map(CsmsCall::RequestStartTransaction)
.map_err(DecodeError::Invalid),
Action::RequestStopTransaction => ocpp_core::decode_value(payload)
.map(CsmsCall::RequestStopTransaction)
.map_err(DecodeError::Invalid),
Action::ReserveNow => ocpp_core::decode_value(payload)
.map(CsmsCall::ReserveNow)
.map_err(DecodeError::Invalid),
Action::Reset => ocpp_core::decode_value(payload)
.map(CsmsCall::Reset)
.map_err(DecodeError::Invalid),
Action::SendLocalList => ocpp_core::decode_value(payload)
.map(CsmsCall::SendLocalList)
.map_err(DecodeError::Invalid),
Action::SetChargingProfile => ocpp_core::decode_value(payload)
.map(CsmsCall::SetChargingProfile)
.map_err(DecodeError::Invalid),
Action::SetDERControl => ocpp_core::decode_value(payload)
.map(CsmsCall::SetDERControl)
.map_err(DecodeError::Invalid),
Action::SetDefaultTariff => ocpp_core::decode_value(payload)
.map(CsmsCall::SetDefaultTariff)
.map_err(DecodeError::Invalid),
Action::SetDisplayMessage => ocpp_core::decode_value(payload)
.map(CsmsCall::SetDisplayMessage)
.map_err(DecodeError::Invalid),
Action::SetMonitoringBase => ocpp_core::decode_value(payload)
.map(CsmsCall::SetMonitoringBase)
.map_err(DecodeError::Invalid),
Action::SetMonitoringLevel => ocpp_core::decode_value(payload)
.map(CsmsCall::SetMonitoringLevel)
.map_err(DecodeError::Invalid),
Action::SetNetworkProfile => ocpp_core::decode_value(payload)
.map(CsmsCall::SetNetworkProfile)
.map_err(DecodeError::Invalid),
Action::SetVariableMonitoring => ocpp_core::decode_value(payload)
.map(CsmsCall::SetVariableMonitoring)
.map_err(DecodeError::Invalid),
Action::SetVariables => ocpp_core::decode_value(payload)
.map(CsmsCall::SetVariables)
.map_err(DecodeError::Invalid),
Action::TriggerMessage => ocpp_core::decode_value(payload)
.map(CsmsCall::TriggerMessage)
.map_err(DecodeError::Invalid),
Action::UnlockConnector => ocpp_core::decode_value(payload)
.map(CsmsCall::UnlockConnector)
.map_err(DecodeError::Invalid),
Action::UnpublishFirmware => ocpp_core::decode_value(payload)
.map(CsmsCall::UnpublishFirmware)
.map_err(DecodeError::Invalid),
Action::UpdateDynamicSchedule => ocpp_core::decode_value(payload)
.map(CsmsCall::UpdateDynamicSchedule)
.map_err(DecodeError::Invalid),
Action::UpdateFirmware => ocpp_core::decode_value(payload)
.map(CsmsCall::UpdateFirmware)
.map_err(DecodeError::Invalid),
Action::UsePriorityCharging => ocpp_core::decode_value(payload)
.map(CsmsCall::UsePriorityCharging)
.map_err(DecodeError::Invalid),
#[allow(unreachable_patterns)]
other => Err(DecodeError::WrongDirection(other)),
}
}
pub fn to_payload(&self) -> serde_json::Value {
match self {
CsmsCall::AFRRSignal(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::AdjustPeriodicEventStream(r) => {
serde_json::to_value(r).expect("serializable")
}
CsmsCall::CancelReservation(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::CertificateSigned(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::ChangeAvailability(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::ChangeTransactionTariff(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::ClearCache(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::ClearChargingProfile(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::ClearDERControl(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::ClearDisplayMessage(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::ClearTariffs(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::ClearVariableMonitoring(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::CostUpdated(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::CustomerInformation(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::DataTransfer(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::DeleteCertificate(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::GetBaseReport(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::GetChargingProfiles(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::GetCompositeSchedule(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::GetDERControl(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::GetDisplayMessages(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::GetInstalledCertificateIds(r) => {
serde_json::to_value(r).expect("serializable")
}
CsmsCall::GetLocalListVersion(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::GetLog(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::GetMonitoringReport(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::GetPeriodicEventStream(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::GetReport(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::GetTariffs(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::GetTransactionStatus(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::GetVariables(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::InstallCertificate(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::NotifyAllowedEnergyTransfer(r) => {
serde_json::to_value(r).expect("serializable")
}
CsmsCall::NotifyWebPaymentStarted(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::PublishFirmware(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::RequestBatterySwap(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::RequestStartTransaction(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::RequestStopTransaction(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::ReserveNow(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::Reset(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::SendLocalList(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::SetChargingProfile(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::SetDERControl(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::SetDefaultTariff(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::SetDisplayMessage(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::SetMonitoringBase(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::SetMonitoringLevel(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::SetNetworkProfile(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::SetVariableMonitoring(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::SetVariables(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::TriggerMessage(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::UnlockConnector(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::UnpublishFirmware(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::UpdateDynamicSchedule(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::UpdateFirmware(r) => serde_json::to_value(r).expect("serializable"),
CsmsCall::UsePriorityCharging(r) => serde_json::to_value(r).expect("serializable"),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum StationSend {
NotifyPeriodicEventStream(NotifyPeriodicEventStream),
}
impl StationSend {
pub fn decode(action: &str, payload: &str) -> Result<Self, DecodeError> {
let a = Action::from_name(action)
.ok_or_else(|| DecodeError::UnknownAction(action.to_owned()))?;
match a {
Action::NotifyPeriodicEventStream => ocpp_core::decode_payload(payload)
.map(StationSend::NotifyPeriodicEventStream)
.map_err(DecodeError::Invalid),
other => Err(DecodeError::WrongDirection(other)),
}
}
}
pub fn validate_response(action: Action, payload: &str) -> Result<serde_json::Value, Violation> {
match action {
Action::AFRRSignal => ocpp_core::decode_payload::<AFRRSignalResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::AdjustPeriodicEventStream => {
ocpp_core::decode_payload::<AdjustPeriodicEventStreamResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::Authorize => ocpp_core::decode_payload::<AuthorizeResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::BatterySwap => ocpp_core::decode_payload::<BatterySwapResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::BootNotification => ocpp_core::decode_payload::<BootNotificationResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::CancelReservation => {
ocpp_core::decode_payload::<CancelReservationResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::CertificateSigned => {
ocpp_core::decode_payload::<CertificateSignedResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::ChangeAvailability => {
ocpp_core::decode_payload::<ChangeAvailabilityResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::ChangeTransactionTariff => {
ocpp_core::decode_payload::<ChangeTransactionTariffResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::ClearCache => ocpp_core::decode_payload::<ClearCacheResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::ClearChargingProfile => {
ocpp_core::decode_payload::<ClearChargingProfileResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::ClearDERControl => ocpp_core::decode_payload::<ClearDERControlResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::ClearDisplayMessage => {
ocpp_core::decode_payload::<ClearDisplayMessageResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::ClearTariffs => ocpp_core::decode_payload::<ClearTariffsResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::ClearVariableMonitoring => {
ocpp_core::decode_payload::<ClearVariableMonitoringResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::ClearedChargingLimit => {
ocpp_core::decode_payload::<ClearedChargingLimitResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::ClosePeriodicEventStream => {
ocpp_core::decode_payload::<ClosePeriodicEventStreamResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::CostUpdated => ocpp_core::decode_payload::<CostUpdatedResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::CustomerInformation => {
ocpp_core::decode_payload::<CustomerInformationResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::DataTransfer => ocpp_core::decode_payload::<DataTransferResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::DeleteCertificate => {
ocpp_core::decode_payload::<DeleteCertificateResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::FirmwareStatusNotification => {
ocpp_core::decode_payload::<FirmwareStatusNotificationResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::Get15118EVCertificate => {
ocpp_core::decode_payload::<Get15118EVCertificateResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::GetBaseReport => ocpp_core::decode_payload::<GetBaseReportResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::GetCertificateChainStatus => {
ocpp_core::decode_payload::<GetCertificateChainStatusResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::GetCertificateStatus => {
ocpp_core::decode_payload::<GetCertificateStatusResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::GetChargingProfiles => {
ocpp_core::decode_payload::<GetChargingProfilesResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::GetCompositeSchedule => {
ocpp_core::decode_payload::<GetCompositeScheduleResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::GetDERControl => ocpp_core::decode_payload::<GetDERControlResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::GetDisplayMessages => {
ocpp_core::decode_payload::<GetDisplayMessagesResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::GetInstalledCertificateIds => {
ocpp_core::decode_payload::<GetInstalledCertificateIdsResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::GetLocalListVersion => {
ocpp_core::decode_payload::<GetLocalListVersionResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::GetLog => ocpp_core::decode_payload::<GetLogResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::GetMonitoringReport => {
ocpp_core::decode_payload::<GetMonitoringReportResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::GetPeriodicEventStream => {
ocpp_core::decode_payload::<GetPeriodicEventStreamResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::GetReport => ocpp_core::decode_payload::<GetReportResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::GetTariffs => ocpp_core::decode_payload::<GetTariffsResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::GetTransactionStatus => {
ocpp_core::decode_payload::<GetTransactionStatusResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::GetVariables => ocpp_core::decode_payload::<GetVariablesResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::Heartbeat => ocpp_core::decode_payload::<HeartbeatResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::InstallCertificate => {
ocpp_core::decode_payload::<InstallCertificateResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::LogStatusNotification => {
ocpp_core::decode_payload::<LogStatusNotificationResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::MeterValues => ocpp_core::decode_payload::<MeterValuesResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::NotifyAllowedEnergyTransfer => {
ocpp_core::decode_payload::<NotifyAllowedEnergyTransferResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::NotifyChargingLimit => {
ocpp_core::decode_payload::<NotifyChargingLimitResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::NotifyCustomerInformation => {
ocpp_core::decode_payload::<NotifyCustomerInformationResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::NotifyDERAlarm => ocpp_core::decode_payload::<NotifyDERAlarmResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::NotifyDERStartStop => {
ocpp_core::decode_payload::<NotifyDERStartStopResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::NotifyDisplayMessages => {
ocpp_core::decode_payload::<NotifyDisplayMessagesResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::NotifyEVChargingNeeds => {
ocpp_core::decode_payload::<NotifyEVChargingNeedsResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::NotifyEVChargingSchedule => {
ocpp_core::decode_payload::<NotifyEVChargingScheduleResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::NotifyEvent => ocpp_core::decode_payload::<NotifyEventResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::NotifyMonitoringReport => {
ocpp_core::decode_payload::<NotifyMonitoringReportResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::NotifyPriorityCharging => {
ocpp_core::decode_payload::<NotifyPriorityChargingResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::NotifyReport => ocpp_core::decode_payload::<NotifyReportResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::NotifySettlement => ocpp_core::decode_payload::<NotifySettlementResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::NotifyWebPaymentStarted => {
ocpp_core::decode_payload::<NotifyWebPaymentStartedResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::OpenPeriodicEventStream => {
ocpp_core::decode_payload::<OpenPeriodicEventStreamResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::PublishFirmware => ocpp_core::decode_payload::<PublishFirmwareResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::PublishFirmwareStatusNotification => {
ocpp_core::decode_payload::<PublishFirmwareStatusNotificationResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::PullDynamicScheduleUpdate => {
ocpp_core::decode_payload::<PullDynamicScheduleUpdateResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::ReportChargingProfiles => {
ocpp_core::decode_payload::<ReportChargingProfilesResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::ReportDERControl => ocpp_core::decode_payload::<ReportDERControlResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::RequestBatterySwap => {
ocpp_core::decode_payload::<RequestBatterySwapResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::RequestStartTransaction => {
ocpp_core::decode_payload::<RequestStartTransactionResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::RequestStopTransaction => {
ocpp_core::decode_payload::<RequestStopTransactionResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::ReservationStatusUpdate => {
ocpp_core::decode_payload::<ReservationStatusUpdateResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::ReserveNow => ocpp_core::decode_payload::<ReserveNowResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::Reset => ocpp_core::decode_payload::<ResetResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::SecurityEventNotification => {
ocpp_core::decode_payload::<SecurityEventNotificationResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::SendLocalList => ocpp_core::decode_payload::<SendLocalListResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::SetChargingProfile => {
ocpp_core::decode_payload::<SetChargingProfileResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::SetDERControl => ocpp_core::decode_payload::<SetDERControlResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::SetDefaultTariff => ocpp_core::decode_payload::<SetDefaultTariffResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::SetDisplayMessage => {
ocpp_core::decode_payload::<SetDisplayMessageResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::SetMonitoringBase => {
ocpp_core::decode_payload::<SetMonitoringBaseResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::SetMonitoringLevel => {
ocpp_core::decode_payload::<SetMonitoringLevelResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::SetNetworkProfile => {
ocpp_core::decode_payload::<SetNetworkProfileResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::SetVariableMonitoring => {
ocpp_core::decode_payload::<SetVariableMonitoringResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::SetVariables => ocpp_core::decode_payload::<SetVariablesResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::SignCertificate => ocpp_core::decode_payload::<SignCertificateResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::StatusNotification => {
ocpp_core::decode_payload::<StatusNotificationResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::TransactionEvent => ocpp_core::decode_payload::<TransactionEventResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::TriggerMessage => ocpp_core::decode_payload::<TriggerMessageResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::UnlockConnector => ocpp_core::decode_payload::<UnlockConnectorResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::UnpublishFirmware => {
ocpp_core::decode_payload::<UnpublishFirmwareResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::UpdateDynamicSchedule => {
ocpp_core::decode_payload::<UpdateDynamicScheduleResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::UpdateFirmware => ocpp_core::decode_payload::<UpdateFirmwareResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable")),
Action::UsePriorityCharging => {
ocpp_core::decode_payload::<UsePriorityChargingResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
Action::VatNumberValidation => {
ocpp_core::decode_payload::<VatNumberValidationResponse>(payload)
.map(|r| serde_json::to_value(r).expect("serializable"))
}
_ => Err(Violation::new(
ocpp_core::ViolationKind::Format,
"SEND messages have no response",
)),
}
}