1#![allow(clippy::large_enum_variant)]
8
9use ocpp_core::validate::Violation;
10
11use crate::messages::*;
12
13impl ocpp_core::Request for AFRRSignalRequest {
14 const ACTION: &'static str = "AFRRSignal";
15 type Response = AFRRSignalResponse;
16}
17
18impl ocpp_core::Request for AdjustPeriodicEventStreamRequest {
19 const ACTION: &'static str = "AdjustPeriodicEventStream";
20 type Response = AdjustPeriodicEventStreamResponse;
21}
22
23impl ocpp_core::Request for AuthorizeRequest {
24 const ACTION: &'static str = "Authorize";
25 type Response = AuthorizeResponse;
26}
27
28impl ocpp_core::Request for BatterySwapRequest {
29 const ACTION: &'static str = "BatterySwap";
30 type Response = BatterySwapResponse;
31}
32
33impl ocpp_core::Request for BootNotificationRequest {
34 const ACTION: &'static str = "BootNotification";
35 type Response = BootNotificationResponse;
36}
37
38impl ocpp_core::Request for CancelReservationRequest {
39 const ACTION: &'static str = "CancelReservation";
40 type Response = CancelReservationResponse;
41}
42
43impl ocpp_core::Request for CertificateSignedRequest {
44 const ACTION: &'static str = "CertificateSigned";
45 type Response = CertificateSignedResponse;
46}
47
48impl ocpp_core::Request for ChangeAvailabilityRequest {
49 const ACTION: &'static str = "ChangeAvailability";
50 type Response = ChangeAvailabilityResponse;
51}
52
53impl ocpp_core::Request for ChangeTransactionTariffRequest {
54 const ACTION: &'static str = "ChangeTransactionTariff";
55 type Response = ChangeTransactionTariffResponse;
56}
57
58impl ocpp_core::Request for ClearCacheRequest {
59 const ACTION: &'static str = "ClearCache";
60 type Response = ClearCacheResponse;
61}
62
63impl ocpp_core::Request for ClearChargingProfileRequest {
64 const ACTION: &'static str = "ClearChargingProfile";
65 type Response = ClearChargingProfileResponse;
66}
67
68impl ocpp_core::Request for ClearDERControlRequest {
69 const ACTION: &'static str = "ClearDERControl";
70 type Response = ClearDERControlResponse;
71}
72
73impl ocpp_core::Request for ClearDisplayMessageRequest {
74 const ACTION: &'static str = "ClearDisplayMessage";
75 type Response = ClearDisplayMessageResponse;
76}
77
78impl ocpp_core::Request for ClearTariffsRequest {
79 const ACTION: &'static str = "ClearTariffs";
80 type Response = ClearTariffsResponse;
81}
82
83impl ocpp_core::Request for ClearVariableMonitoringRequest {
84 const ACTION: &'static str = "ClearVariableMonitoring";
85 type Response = ClearVariableMonitoringResponse;
86}
87
88impl ocpp_core::Request for ClearedChargingLimitRequest {
89 const ACTION: &'static str = "ClearedChargingLimit";
90 type Response = ClearedChargingLimitResponse;
91}
92
93impl ocpp_core::Request for ClosePeriodicEventStreamRequest {
94 const ACTION: &'static str = "ClosePeriodicEventStream";
95 type Response = ClosePeriodicEventStreamResponse;
96}
97
98impl ocpp_core::Request for CostUpdatedRequest {
99 const ACTION: &'static str = "CostUpdated";
100 type Response = CostUpdatedResponse;
101}
102
103impl ocpp_core::Request for CustomerInformationRequest {
104 const ACTION: &'static str = "CustomerInformation";
105 type Response = CustomerInformationResponse;
106}
107
108impl ocpp_core::Request for DataTransferRequest {
109 const ACTION: &'static str = "DataTransfer";
110 type Response = DataTransferResponse;
111}
112
113impl ocpp_core::Request for DeleteCertificateRequest {
114 const ACTION: &'static str = "DeleteCertificate";
115 type Response = DeleteCertificateResponse;
116}
117
118impl ocpp_core::Request for FirmwareStatusNotificationRequest {
119 const ACTION: &'static str = "FirmwareStatusNotification";
120 type Response = FirmwareStatusNotificationResponse;
121}
122
123impl ocpp_core::Request for Get15118EVCertificateRequest {
124 const ACTION: &'static str = "Get15118EVCertificate";
125 type Response = Get15118EVCertificateResponse;
126}
127
128impl ocpp_core::Request for GetBaseReportRequest {
129 const ACTION: &'static str = "GetBaseReport";
130 type Response = GetBaseReportResponse;
131}
132
133impl ocpp_core::Request for GetCertificateChainStatusRequest {
134 const ACTION: &'static str = "GetCertificateChainStatus";
135 type Response = GetCertificateChainStatusResponse;
136}
137
138impl ocpp_core::Request for GetCertificateStatusRequest {
139 const ACTION: &'static str = "GetCertificateStatus";
140 type Response = GetCertificateStatusResponse;
141}
142
143impl ocpp_core::Request for GetChargingProfilesRequest {
144 const ACTION: &'static str = "GetChargingProfiles";
145 type Response = GetChargingProfilesResponse;
146}
147
148impl ocpp_core::Request for GetCompositeScheduleRequest {
149 const ACTION: &'static str = "GetCompositeSchedule";
150 type Response = GetCompositeScheduleResponse;
151}
152
153impl ocpp_core::Request for GetDERControlRequest {
154 const ACTION: &'static str = "GetDERControl";
155 type Response = GetDERControlResponse;
156}
157
158impl ocpp_core::Request for GetDisplayMessagesRequest {
159 const ACTION: &'static str = "GetDisplayMessages";
160 type Response = GetDisplayMessagesResponse;
161}
162
163impl ocpp_core::Request for GetInstalledCertificateIdsRequest {
164 const ACTION: &'static str = "GetInstalledCertificateIds";
165 type Response = GetInstalledCertificateIdsResponse;
166}
167
168impl ocpp_core::Request for GetLocalListVersionRequest {
169 const ACTION: &'static str = "GetLocalListVersion";
170 type Response = GetLocalListVersionResponse;
171}
172
173impl ocpp_core::Request for GetLogRequest {
174 const ACTION: &'static str = "GetLog";
175 type Response = GetLogResponse;
176}
177
178impl ocpp_core::Request for GetMonitoringReportRequest {
179 const ACTION: &'static str = "GetMonitoringReport";
180 type Response = GetMonitoringReportResponse;
181}
182
183impl ocpp_core::Request for GetPeriodicEventStreamRequest {
184 const ACTION: &'static str = "GetPeriodicEventStream";
185 type Response = GetPeriodicEventStreamResponse;
186}
187
188impl ocpp_core::Request for GetReportRequest {
189 const ACTION: &'static str = "GetReport";
190 type Response = GetReportResponse;
191}
192
193impl ocpp_core::Request for GetTariffsRequest {
194 const ACTION: &'static str = "GetTariffs";
195 type Response = GetTariffsResponse;
196}
197
198impl ocpp_core::Request for GetTransactionStatusRequest {
199 const ACTION: &'static str = "GetTransactionStatus";
200 type Response = GetTransactionStatusResponse;
201}
202
203impl ocpp_core::Request for GetVariablesRequest {
204 const ACTION: &'static str = "GetVariables";
205 type Response = GetVariablesResponse;
206}
207
208impl ocpp_core::Request for HeartbeatRequest {
209 const ACTION: &'static str = "Heartbeat";
210 type Response = HeartbeatResponse;
211}
212
213impl ocpp_core::Request for InstallCertificateRequest {
214 const ACTION: &'static str = "InstallCertificate";
215 type Response = InstallCertificateResponse;
216}
217
218impl ocpp_core::Request for LogStatusNotificationRequest {
219 const ACTION: &'static str = "LogStatusNotification";
220 type Response = LogStatusNotificationResponse;
221}
222
223impl ocpp_core::Request for MeterValuesRequest {
224 const ACTION: &'static str = "MeterValues";
225 type Response = MeterValuesResponse;
226}
227
228impl ocpp_core::Request for NotifyAllowedEnergyTransferRequest {
229 const ACTION: &'static str = "NotifyAllowedEnergyTransfer";
230 type Response = NotifyAllowedEnergyTransferResponse;
231}
232
233impl ocpp_core::Request for NotifyChargingLimitRequest {
234 const ACTION: &'static str = "NotifyChargingLimit";
235 type Response = NotifyChargingLimitResponse;
236}
237
238impl ocpp_core::Request for NotifyCustomerInformationRequest {
239 const ACTION: &'static str = "NotifyCustomerInformation";
240 type Response = NotifyCustomerInformationResponse;
241}
242
243impl ocpp_core::Request for NotifyDERAlarmRequest {
244 const ACTION: &'static str = "NotifyDERAlarm";
245 type Response = NotifyDERAlarmResponse;
246}
247
248impl ocpp_core::Request for NotifyDERStartStopRequest {
249 const ACTION: &'static str = "NotifyDERStartStop";
250 type Response = NotifyDERStartStopResponse;
251}
252
253impl ocpp_core::Request for NotifyDisplayMessagesRequest {
254 const ACTION: &'static str = "NotifyDisplayMessages";
255 type Response = NotifyDisplayMessagesResponse;
256}
257
258impl ocpp_core::Request for NotifyEVChargingNeedsRequest {
259 const ACTION: &'static str = "NotifyEVChargingNeeds";
260 type Response = NotifyEVChargingNeedsResponse;
261}
262
263impl ocpp_core::Request for NotifyEVChargingScheduleRequest {
264 const ACTION: &'static str = "NotifyEVChargingSchedule";
265 type Response = NotifyEVChargingScheduleResponse;
266}
267
268impl ocpp_core::Request for NotifyEventRequest {
269 const ACTION: &'static str = "NotifyEvent";
270 type Response = NotifyEventResponse;
271}
272
273impl ocpp_core::Request for NotifyMonitoringReportRequest {
274 const ACTION: &'static str = "NotifyMonitoringReport";
275 type Response = NotifyMonitoringReportResponse;
276}
277
278impl ocpp_core::Request for NotifyPriorityChargingRequest {
279 const ACTION: &'static str = "NotifyPriorityCharging";
280 type Response = NotifyPriorityChargingResponse;
281}
282
283impl ocpp_core::Request for NotifyReportRequest {
284 const ACTION: &'static str = "NotifyReport";
285 type Response = NotifyReportResponse;
286}
287
288impl ocpp_core::Request for NotifySettlementRequest {
289 const ACTION: &'static str = "NotifySettlement";
290 type Response = NotifySettlementResponse;
291}
292
293impl ocpp_core::Request for NotifyWebPaymentStartedRequest {
294 const ACTION: &'static str = "NotifyWebPaymentStarted";
295 type Response = NotifyWebPaymentStartedResponse;
296}
297
298impl ocpp_core::Request for OpenPeriodicEventStreamRequest {
299 const ACTION: &'static str = "OpenPeriodicEventStream";
300 type Response = OpenPeriodicEventStreamResponse;
301}
302
303impl ocpp_core::Request for PublishFirmwareRequest {
304 const ACTION: &'static str = "PublishFirmware";
305 type Response = PublishFirmwareResponse;
306}
307
308impl ocpp_core::Request for PublishFirmwareStatusNotificationRequest {
309 const ACTION: &'static str = "PublishFirmwareStatusNotification";
310 type Response = PublishFirmwareStatusNotificationResponse;
311}
312
313impl ocpp_core::Request for PullDynamicScheduleUpdateRequest {
314 const ACTION: &'static str = "PullDynamicScheduleUpdate";
315 type Response = PullDynamicScheduleUpdateResponse;
316}
317
318impl ocpp_core::Request for ReportChargingProfilesRequest {
319 const ACTION: &'static str = "ReportChargingProfiles";
320 type Response = ReportChargingProfilesResponse;
321}
322
323impl ocpp_core::Request for ReportDERControlRequest {
324 const ACTION: &'static str = "ReportDERControl";
325 type Response = ReportDERControlResponse;
326}
327
328impl ocpp_core::Request for RequestBatterySwapRequest {
329 const ACTION: &'static str = "RequestBatterySwap";
330 type Response = RequestBatterySwapResponse;
331}
332
333impl ocpp_core::Request for RequestStartTransactionRequest {
334 const ACTION: &'static str = "RequestStartTransaction";
335 type Response = RequestStartTransactionResponse;
336}
337
338impl ocpp_core::Request for RequestStopTransactionRequest {
339 const ACTION: &'static str = "RequestStopTransaction";
340 type Response = RequestStopTransactionResponse;
341}
342
343impl ocpp_core::Request for ReservationStatusUpdateRequest {
344 const ACTION: &'static str = "ReservationStatusUpdate";
345 type Response = ReservationStatusUpdateResponse;
346}
347
348impl ocpp_core::Request for ReserveNowRequest {
349 const ACTION: &'static str = "ReserveNow";
350 type Response = ReserveNowResponse;
351}
352
353impl ocpp_core::Request for ResetRequest {
354 const ACTION: &'static str = "Reset";
355 type Response = ResetResponse;
356}
357
358impl ocpp_core::Request for SecurityEventNotificationRequest {
359 const ACTION: &'static str = "SecurityEventNotification";
360 type Response = SecurityEventNotificationResponse;
361}
362
363impl ocpp_core::Request for SendLocalListRequest {
364 const ACTION: &'static str = "SendLocalList";
365 type Response = SendLocalListResponse;
366}
367
368impl ocpp_core::Request for SetChargingProfileRequest {
369 const ACTION: &'static str = "SetChargingProfile";
370 type Response = SetChargingProfileResponse;
371}
372
373impl ocpp_core::Request for SetDERControlRequest {
374 const ACTION: &'static str = "SetDERControl";
375 type Response = SetDERControlResponse;
376}
377
378impl ocpp_core::Request for SetDefaultTariffRequest {
379 const ACTION: &'static str = "SetDefaultTariff";
380 type Response = SetDefaultTariffResponse;
381}
382
383impl ocpp_core::Request for SetDisplayMessageRequest {
384 const ACTION: &'static str = "SetDisplayMessage";
385 type Response = SetDisplayMessageResponse;
386}
387
388impl ocpp_core::Request for SetMonitoringBaseRequest {
389 const ACTION: &'static str = "SetMonitoringBase";
390 type Response = SetMonitoringBaseResponse;
391}
392
393impl ocpp_core::Request for SetMonitoringLevelRequest {
394 const ACTION: &'static str = "SetMonitoringLevel";
395 type Response = SetMonitoringLevelResponse;
396}
397
398impl ocpp_core::Request for SetNetworkProfileRequest {
399 const ACTION: &'static str = "SetNetworkProfile";
400 type Response = SetNetworkProfileResponse;
401}
402
403impl ocpp_core::Request for SetVariableMonitoringRequest {
404 const ACTION: &'static str = "SetVariableMonitoring";
405 type Response = SetVariableMonitoringResponse;
406}
407
408impl ocpp_core::Request for SetVariablesRequest {
409 const ACTION: &'static str = "SetVariables";
410 type Response = SetVariablesResponse;
411}
412
413impl ocpp_core::Request for SignCertificateRequest {
414 const ACTION: &'static str = "SignCertificate";
415 type Response = SignCertificateResponse;
416}
417
418impl ocpp_core::Request for StatusNotificationRequest {
419 const ACTION: &'static str = "StatusNotification";
420 type Response = StatusNotificationResponse;
421}
422
423impl ocpp_core::Request for TransactionEventRequest {
424 const ACTION: &'static str = "TransactionEvent";
425 type Response = TransactionEventResponse;
426}
427
428impl ocpp_core::Request for TriggerMessageRequest {
429 const ACTION: &'static str = "TriggerMessage";
430 type Response = TriggerMessageResponse;
431}
432
433impl ocpp_core::Request for UnlockConnectorRequest {
434 const ACTION: &'static str = "UnlockConnector";
435 type Response = UnlockConnectorResponse;
436}
437
438impl ocpp_core::Request for UnpublishFirmwareRequest {
439 const ACTION: &'static str = "UnpublishFirmware";
440 type Response = UnpublishFirmwareResponse;
441}
442
443impl ocpp_core::Request for UpdateDynamicScheduleRequest {
444 const ACTION: &'static str = "UpdateDynamicSchedule";
445 type Response = UpdateDynamicScheduleResponse;
446}
447
448impl ocpp_core::Request for UpdateFirmwareRequest {
449 const ACTION: &'static str = "UpdateFirmware";
450 type Response = UpdateFirmwareResponse;
451}
452
453impl ocpp_core::Request for UsePriorityChargingRequest {
454 const ACTION: &'static str = "UsePriorityCharging";
455 type Response = UsePriorityChargingResponse;
456}
457
458impl ocpp_core::Request for VatNumberValidationRequest {
459 const ACTION: &'static str = "VatNumberValidation";
460 type Response = VatNumberValidationResponse;
461}
462
463#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
465pub enum Direction {
466 StationToCsms,
468 CsmsToStation,
470 Both,
472}
473
474#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
476pub enum Action {
477 AFRRSignal,
478 AdjustPeriodicEventStream,
479 Authorize,
480 BatterySwap,
481 BootNotification,
482 CancelReservation,
483 CertificateSigned,
484 ChangeAvailability,
485 ChangeTransactionTariff,
486 ClearCache,
487 ClearChargingProfile,
488 ClearDERControl,
489 ClearDisplayMessage,
490 ClearTariffs,
491 ClearVariableMonitoring,
492 ClearedChargingLimit,
493 ClosePeriodicEventStream,
494 CostUpdated,
495 CustomerInformation,
496 DataTransfer,
497 DeleteCertificate,
498 FirmwareStatusNotification,
499 Get15118EVCertificate,
500 GetBaseReport,
501 GetCertificateChainStatus,
502 GetCertificateStatus,
503 GetChargingProfiles,
504 GetCompositeSchedule,
505 GetDERControl,
506 GetDisplayMessages,
507 GetInstalledCertificateIds,
508 GetLocalListVersion,
509 GetLog,
510 GetMonitoringReport,
511 GetPeriodicEventStream,
512 GetReport,
513 GetTariffs,
514 GetTransactionStatus,
515 GetVariables,
516 Heartbeat,
517 InstallCertificate,
518 LogStatusNotification,
519 MeterValues,
520 NotifyAllowedEnergyTransfer,
521 NotifyChargingLimit,
522 NotifyCustomerInformation,
523 NotifyDERAlarm,
524 NotifyDERStartStop,
525 NotifyDisplayMessages,
526 NotifyEVChargingNeeds,
527 NotifyEVChargingSchedule,
528 NotifyEvent,
529 NotifyMonitoringReport,
530 NotifyPeriodicEventStream,
531 NotifyPriorityCharging,
532 NotifyReport,
533 NotifySettlement,
534 NotifyWebPaymentStarted,
535 OpenPeriodicEventStream,
536 PublishFirmware,
537 PublishFirmwareStatusNotification,
538 PullDynamicScheduleUpdate,
539 ReportChargingProfiles,
540 ReportDERControl,
541 RequestBatterySwap,
542 RequestStartTransaction,
543 RequestStopTransaction,
544 ReservationStatusUpdate,
545 ReserveNow,
546 Reset,
547 SecurityEventNotification,
548 SendLocalList,
549 SetChargingProfile,
550 SetDERControl,
551 SetDefaultTariff,
552 SetDisplayMessage,
553 SetMonitoringBase,
554 SetMonitoringLevel,
555 SetNetworkProfile,
556 SetVariableMonitoring,
557 SetVariables,
558 SignCertificate,
559 StatusNotification,
560 TransactionEvent,
561 TriggerMessage,
562 UnlockConnector,
563 UnpublishFirmware,
564 UpdateDynamicSchedule,
565 UpdateFirmware,
566 UsePriorityCharging,
567 VatNumberValidation,
568}
569
570impl Action {
571 pub const ALL: &'static [Action] = &[
572 Action::AFRRSignal,
573 Action::AdjustPeriodicEventStream,
574 Action::Authorize,
575 Action::BatterySwap,
576 Action::BootNotification,
577 Action::CancelReservation,
578 Action::CertificateSigned,
579 Action::ChangeAvailability,
580 Action::ChangeTransactionTariff,
581 Action::ClearCache,
582 Action::ClearChargingProfile,
583 Action::ClearDERControl,
584 Action::ClearDisplayMessage,
585 Action::ClearTariffs,
586 Action::ClearVariableMonitoring,
587 Action::ClearedChargingLimit,
588 Action::ClosePeriodicEventStream,
589 Action::CostUpdated,
590 Action::CustomerInformation,
591 Action::DataTransfer,
592 Action::DeleteCertificate,
593 Action::FirmwareStatusNotification,
594 Action::Get15118EVCertificate,
595 Action::GetBaseReport,
596 Action::GetCertificateChainStatus,
597 Action::GetCertificateStatus,
598 Action::GetChargingProfiles,
599 Action::GetCompositeSchedule,
600 Action::GetDERControl,
601 Action::GetDisplayMessages,
602 Action::GetInstalledCertificateIds,
603 Action::GetLocalListVersion,
604 Action::GetLog,
605 Action::GetMonitoringReport,
606 Action::GetPeriodicEventStream,
607 Action::GetReport,
608 Action::GetTariffs,
609 Action::GetTransactionStatus,
610 Action::GetVariables,
611 Action::Heartbeat,
612 Action::InstallCertificate,
613 Action::LogStatusNotification,
614 Action::MeterValues,
615 Action::NotifyAllowedEnergyTransfer,
616 Action::NotifyChargingLimit,
617 Action::NotifyCustomerInformation,
618 Action::NotifyDERAlarm,
619 Action::NotifyDERStartStop,
620 Action::NotifyDisplayMessages,
621 Action::NotifyEVChargingNeeds,
622 Action::NotifyEVChargingSchedule,
623 Action::NotifyEvent,
624 Action::NotifyMonitoringReport,
625 Action::NotifyPeriodicEventStream,
626 Action::NotifyPriorityCharging,
627 Action::NotifyReport,
628 Action::NotifySettlement,
629 Action::NotifyWebPaymentStarted,
630 Action::OpenPeriodicEventStream,
631 Action::PublishFirmware,
632 Action::PublishFirmwareStatusNotification,
633 Action::PullDynamicScheduleUpdate,
634 Action::ReportChargingProfiles,
635 Action::ReportDERControl,
636 Action::RequestBatterySwap,
637 Action::RequestStartTransaction,
638 Action::RequestStopTransaction,
639 Action::ReservationStatusUpdate,
640 Action::ReserveNow,
641 Action::Reset,
642 Action::SecurityEventNotification,
643 Action::SendLocalList,
644 Action::SetChargingProfile,
645 Action::SetDERControl,
646 Action::SetDefaultTariff,
647 Action::SetDisplayMessage,
648 Action::SetMonitoringBase,
649 Action::SetMonitoringLevel,
650 Action::SetNetworkProfile,
651 Action::SetVariableMonitoring,
652 Action::SetVariables,
653 Action::SignCertificate,
654 Action::StatusNotification,
655 Action::TransactionEvent,
656 Action::TriggerMessage,
657 Action::UnlockConnector,
658 Action::UnpublishFirmware,
659 Action::UpdateDynamicSchedule,
660 Action::UpdateFirmware,
661 Action::UsePriorityCharging,
662 Action::VatNumberValidation,
663 ];
664
665 pub const fn as_str(&self) -> &'static str {
666 match self {
667 Action::AFRRSignal => "AFRRSignal",
668 Action::AdjustPeriodicEventStream => "AdjustPeriodicEventStream",
669 Action::Authorize => "Authorize",
670 Action::BatterySwap => "BatterySwap",
671 Action::BootNotification => "BootNotification",
672 Action::CancelReservation => "CancelReservation",
673 Action::CertificateSigned => "CertificateSigned",
674 Action::ChangeAvailability => "ChangeAvailability",
675 Action::ChangeTransactionTariff => "ChangeTransactionTariff",
676 Action::ClearCache => "ClearCache",
677 Action::ClearChargingProfile => "ClearChargingProfile",
678 Action::ClearDERControl => "ClearDERControl",
679 Action::ClearDisplayMessage => "ClearDisplayMessage",
680 Action::ClearTariffs => "ClearTariffs",
681 Action::ClearVariableMonitoring => "ClearVariableMonitoring",
682 Action::ClearedChargingLimit => "ClearedChargingLimit",
683 Action::ClosePeriodicEventStream => "ClosePeriodicEventStream",
684 Action::CostUpdated => "CostUpdated",
685 Action::CustomerInformation => "CustomerInformation",
686 Action::DataTransfer => "DataTransfer",
687 Action::DeleteCertificate => "DeleteCertificate",
688 Action::FirmwareStatusNotification => "FirmwareStatusNotification",
689 Action::Get15118EVCertificate => "Get15118EVCertificate",
690 Action::GetBaseReport => "GetBaseReport",
691 Action::GetCertificateChainStatus => "GetCertificateChainStatus",
692 Action::GetCertificateStatus => "GetCertificateStatus",
693 Action::GetChargingProfiles => "GetChargingProfiles",
694 Action::GetCompositeSchedule => "GetCompositeSchedule",
695 Action::GetDERControl => "GetDERControl",
696 Action::GetDisplayMessages => "GetDisplayMessages",
697 Action::GetInstalledCertificateIds => "GetInstalledCertificateIds",
698 Action::GetLocalListVersion => "GetLocalListVersion",
699 Action::GetLog => "GetLog",
700 Action::GetMonitoringReport => "GetMonitoringReport",
701 Action::GetPeriodicEventStream => "GetPeriodicEventStream",
702 Action::GetReport => "GetReport",
703 Action::GetTariffs => "GetTariffs",
704 Action::GetTransactionStatus => "GetTransactionStatus",
705 Action::GetVariables => "GetVariables",
706 Action::Heartbeat => "Heartbeat",
707 Action::InstallCertificate => "InstallCertificate",
708 Action::LogStatusNotification => "LogStatusNotification",
709 Action::MeterValues => "MeterValues",
710 Action::NotifyAllowedEnergyTransfer => "NotifyAllowedEnergyTransfer",
711 Action::NotifyChargingLimit => "NotifyChargingLimit",
712 Action::NotifyCustomerInformation => "NotifyCustomerInformation",
713 Action::NotifyDERAlarm => "NotifyDERAlarm",
714 Action::NotifyDERStartStop => "NotifyDERStartStop",
715 Action::NotifyDisplayMessages => "NotifyDisplayMessages",
716 Action::NotifyEVChargingNeeds => "NotifyEVChargingNeeds",
717 Action::NotifyEVChargingSchedule => "NotifyEVChargingSchedule",
718 Action::NotifyEvent => "NotifyEvent",
719 Action::NotifyMonitoringReport => "NotifyMonitoringReport",
720 Action::NotifyPeriodicEventStream => "NotifyPeriodicEventStream",
721 Action::NotifyPriorityCharging => "NotifyPriorityCharging",
722 Action::NotifyReport => "NotifyReport",
723 Action::NotifySettlement => "NotifySettlement",
724 Action::NotifyWebPaymentStarted => "NotifyWebPaymentStarted",
725 Action::OpenPeriodicEventStream => "OpenPeriodicEventStream",
726 Action::PublishFirmware => "PublishFirmware",
727 Action::PublishFirmwareStatusNotification => "PublishFirmwareStatusNotification",
728 Action::PullDynamicScheduleUpdate => "PullDynamicScheduleUpdate",
729 Action::ReportChargingProfiles => "ReportChargingProfiles",
730 Action::ReportDERControl => "ReportDERControl",
731 Action::RequestBatterySwap => "RequestBatterySwap",
732 Action::RequestStartTransaction => "RequestStartTransaction",
733 Action::RequestStopTransaction => "RequestStopTransaction",
734 Action::ReservationStatusUpdate => "ReservationStatusUpdate",
735 Action::ReserveNow => "ReserveNow",
736 Action::Reset => "Reset",
737 Action::SecurityEventNotification => "SecurityEventNotification",
738 Action::SendLocalList => "SendLocalList",
739 Action::SetChargingProfile => "SetChargingProfile",
740 Action::SetDERControl => "SetDERControl",
741 Action::SetDefaultTariff => "SetDefaultTariff",
742 Action::SetDisplayMessage => "SetDisplayMessage",
743 Action::SetMonitoringBase => "SetMonitoringBase",
744 Action::SetMonitoringLevel => "SetMonitoringLevel",
745 Action::SetNetworkProfile => "SetNetworkProfile",
746 Action::SetVariableMonitoring => "SetVariableMonitoring",
747 Action::SetVariables => "SetVariables",
748 Action::SignCertificate => "SignCertificate",
749 Action::StatusNotification => "StatusNotification",
750 Action::TransactionEvent => "TransactionEvent",
751 Action::TriggerMessage => "TriggerMessage",
752 Action::UnlockConnector => "UnlockConnector",
753 Action::UnpublishFirmware => "UnpublishFirmware",
754 Action::UpdateDynamicSchedule => "UpdateDynamicSchedule",
755 Action::UpdateFirmware => "UpdateFirmware",
756 Action::UsePriorityCharging => "UsePriorityCharging",
757 Action::VatNumberValidation => "VatNumberValidation",
758 }
759 }
760
761 pub fn from_name(s: &str) -> Option<Action> {
762 match s {
763 "AFRRSignal" => Some(Action::AFRRSignal),
764 "AdjustPeriodicEventStream" => Some(Action::AdjustPeriodicEventStream),
765 "Authorize" => Some(Action::Authorize),
766 "BatterySwap" => Some(Action::BatterySwap),
767 "BootNotification" => Some(Action::BootNotification),
768 "CancelReservation" => Some(Action::CancelReservation),
769 "CertificateSigned" => Some(Action::CertificateSigned),
770 "ChangeAvailability" => Some(Action::ChangeAvailability),
771 "ChangeTransactionTariff" => Some(Action::ChangeTransactionTariff),
772 "ClearCache" => Some(Action::ClearCache),
773 "ClearChargingProfile" => Some(Action::ClearChargingProfile),
774 "ClearDERControl" => Some(Action::ClearDERControl),
775 "ClearDisplayMessage" => Some(Action::ClearDisplayMessage),
776 "ClearTariffs" => Some(Action::ClearTariffs),
777 "ClearVariableMonitoring" => Some(Action::ClearVariableMonitoring),
778 "ClearedChargingLimit" => Some(Action::ClearedChargingLimit),
779 "ClosePeriodicEventStream" => Some(Action::ClosePeriodicEventStream),
780 "CostUpdated" => Some(Action::CostUpdated),
781 "CustomerInformation" => Some(Action::CustomerInformation),
782 "DataTransfer" => Some(Action::DataTransfer),
783 "DeleteCertificate" => Some(Action::DeleteCertificate),
784 "FirmwareStatusNotification" => Some(Action::FirmwareStatusNotification),
785 "Get15118EVCertificate" => Some(Action::Get15118EVCertificate),
786 "GetBaseReport" => Some(Action::GetBaseReport),
787 "GetCertificateChainStatus" => Some(Action::GetCertificateChainStatus),
788 "GetCertificateStatus" => Some(Action::GetCertificateStatus),
789 "GetChargingProfiles" => Some(Action::GetChargingProfiles),
790 "GetCompositeSchedule" => Some(Action::GetCompositeSchedule),
791 "GetDERControl" => Some(Action::GetDERControl),
792 "GetDisplayMessages" => Some(Action::GetDisplayMessages),
793 "GetInstalledCertificateIds" => Some(Action::GetInstalledCertificateIds),
794 "GetLocalListVersion" => Some(Action::GetLocalListVersion),
795 "GetLog" => Some(Action::GetLog),
796 "GetMonitoringReport" => Some(Action::GetMonitoringReport),
797 "GetPeriodicEventStream" => Some(Action::GetPeriodicEventStream),
798 "GetReport" => Some(Action::GetReport),
799 "GetTariffs" => Some(Action::GetTariffs),
800 "GetTransactionStatus" => Some(Action::GetTransactionStatus),
801 "GetVariables" => Some(Action::GetVariables),
802 "Heartbeat" => Some(Action::Heartbeat),
803 "InstallCertificate" => Some(Action::InstallCertificate),
804 "LogStatusNotification" => Some(Action::LogStatusNotification),
805 "MeterValues" => Some(Action::MeterValues),
806 "NotifyAllowedEnergyTransfer" => Some(Action::NotifyAllowedEnergyTransfer),
807 "NotifyChargingLimit" => Some(Action::NotifyChargingLimit),
808 "NotifyCustomerInformation" => Some(Action::NotifyCustomerInformation),
809 "NotifyDERAlarm" => Some(Action::NotifyDERAlarm),
810 "NotifyDERStartStop" => Some(Action::NotifyDERStartStop),
811 "NotifyDisplayMessages" => Some(Action::NotifyDisplayMessages),
812 "NotifyEVChargingNeeds" => Some(Action::NotifyEVChargingNeeds),
813 "NotifyEVChargingSchedule" => Some(Action::NotifyEVChargingSchedule),
814 "NotifyEvent" => Some(Action::NotifyEvent),
815 "NotifyMonitoringReport" => Some(Action::NotifyMonitoringReport),
816 "NotifyPeriodicEventStream" => Some(Action::NotifyPeriodicEventStream),
817 "NotifyPriorityCharging" => Some(Action::NotifyPriorityCharging),
818 "NotifyReport" => Some(Action::NotifyReport),
819 "NotifySettlement" => Some(Action::NotifySettlement),
820 "NotifyWebPaymentStarted" => Some(Action::NotifyWebPaymentStarted),
821 "OpenPeriodicEventStream" => Some(Action::OpenPeriodicEventStream),
822 "PublishFirmware" => Some(Action::PublishFirmware),
823 "PublishFirmwareStatusNotification" => Some(Action::PublishFirmwareStatusNotification),
824 "PullDynamicScheduleUpdate" => Some(Action::PullDynamicScheduleUpdate),
825 "ReportChargingProfiles" => Some(Action::ReportChargingProfiles),
826 "ReportDERControl" => Some(Action::ReportDERControl),
827 "RequestBatterySwap" => Some(Action::RequestBatterySwap),
828 "RequestStartTransaction" => Some(Action::RequestStartTransaction),
829 "RequestStopTransaction" => Some(Action::RequestStopTransaction),
830 "ReservationStatusUpdate" => Some(Action::ReservationStatusUpdate),
831 "ReserveNow" => Some(Action::ReserveNow),
832 "Reset" => Some(Action::Reset),
833 "SecurityEventNotification" => Some(Action::SecurityEventNotification),
834 "SendLocalList" => Some(Action::SendLocalList),
835 "SetChargingProfile" => Some(Action::SetChargingProfile),
836 "SetDERControl" => Some(Action::SetDERControl),
837 "SetDefaultTariff" => Some(Action::SetDefaultTariff),
838 "SetDisplayMessage" => Some(Action::SetDisplayMessage),
839 "SetMonitoringBase" => Some(Action::SetMonitoringBase),
840 "SetMonitoringLevel" => Some(Action::SetMonitoringLevel),
841 "SetNetworkProfile" => Some(Action::SetNetworkProfile),
842 "SetVariableMonitoring" => Some(Action::SetVariableMonitoring),
843 "SetVariables" => Some(Action::SetVariables),
844 "SignCertificate" => Some(Action::SignCertificate),
845 "StatusNotification" => Some(Action::StatusNotification),
846 "TransactionEvent" => Some(Action::TransactionEvent),
847 "TriggerMessage" => Some(Action::TriggerMessage),
848 "UnlockConnector" => Some(Action::UnlockConnector),
849 "UnpublishFirmware" => Some(Action::UnpublishFirmware),
850 "UpdateDynamicSchedule" => Some(Action::UpdateDynamicSchedule),
851 "UpdateFirmware" => Some(Action::UpdateFirmware),
852 "UsePriorityCharging" => Some(Action::UsePriorityCharging),
853 "VatNumberValidation" => Some(Action::VatNumberValidation),
854 _ => None,
855 }
856 }
857
858 pub const fn direction(&self) -> Direction {
859 match self {
860 Action::AFRRSignal => Direction::CsmsToStation,
861 Action::AdjustPeriodicEventStream => Direction::CsmsToStation,
862 Action::Authorize => Direction::StationToCsms,
863 Action::BatterySwap => Direction::StationToCsms,
864 Action::BootNotification => Direction::StationToCsms,
865 Action::CancelReservation => Direction::CsmsToStation,
866 Action::CertificateSigned => Direction::CsmsToStation,
867 Action::ChangeAvailability => Direction::CsmsToStation,
868 Action::ChangeTransactionTariff => Direction::CsmsToStation,
869 Action::ClearCache => Direction::CsmsToStation,
870 Action::ClearChargingProfile => Direction::CsmsToStation,
871 Action::ClearDERControl => Direction::CsmsToStation,
872 Action::ClearDisplayMessage => Direction::CsmsToStation,
873 Action::ClearTariffs => Direction::CsmsToStation,
874 Action::ClearVariableMonitoring => Direction::CsmsToStation,
875 Action::ClearedChargingLimit => Direction::StationToCsms,
876 Action::ClosePeriodicEventStream => Direction::StationToCsms,
877 Action::CostUpdated => Direction::CsmsToStation,
878 Action::CustomerInformation => Direction::CsmsToStation,
879 Action::DataTransfer => Direction::Both,
880 Action::DeleteCertificate => Direction::CsmsToStation,
881 Action::FirmwareStatusNotification => Direction::StationToCsms,
882 Action::Get15118EVCertificate => Direction::StationToCsms,
883 Action::GetBaseReport => Direction::CsmsToStation,
884 Action::GetCertificateChainStatus => Direction::StationToCsms,
885 Action::GetCertificateStatus => Direction::StationToCsms,
886 Action::GetChargingProfiles => Direction::CsmsToStation,
887 Action::GetCompositeSchedule => Direction::CsmsToStation,
888 Action::GetDERControl => Direction::CsmsToStation,
889 Action::GetDisplayMessages => Direction::CsmsToStation,
890 Action::GetInstalledCertificateIds => Direction::CsmsToStation,
891 Action::GetLocalListVersion => Direction::CsmsToStation,
892 Action::GetLog => Direction::CsmsToStation,
893 Action::GetMonitoringReport => Direction::CsmsToStation,
894 Action::GetPeriodicEventStream => Direction::CsmsToStation,
895 Action::GetReport => Direction::CsmsToStation,
896 Action::GetTariffs => Direction::CsmsToStation,
897 Action::GetTransactionStatus => Direction::CsmsToStation,
898 Action::GetVariables => Direction::CsmsToStation,
899 Action::Heartbeat => Direction::StationToCsms,
900 Action::InstallCertificate => Direction::CsmsToStation,
901 Action::LogStatusNotification => Direction::StationToCsms,
902 Action::MeterValues => Direction::StationToCsms,
903 Action::NotifyAllowedEnergyTransfer => Direction::CsmsToStation,
904 Action::NotifyChargingLimit => Direction::StationToCsms,
905 Action::NotifyCustomerInformation => Direction::StationToCsms,
906 Action::NotifyDERAlarm => Direction::StationToCsms,
907 Action::NotifyDERStartStop => Direction::StationToCsms,
908 Action::NotifyDisplayMessages => Direction::StationToCsms,
909 Action::NotifyEVChargingNeeds => Direction::StationToCsms,
910 Action::NotifyEVChargingSchedule => Direction::StationToCsms,
911 Action::NotifyEvent => Direction::StationToCsms,
912 Action::NotifyMonitoringReport => Direction::StationToCsms,
913 Action::NotifyPeriodicEventStream => Direction::StationToCsms,
914 Action::NotifyPriorityCharging => Direction::StationToCsms,
915 Action::NotifyReport => Direction::StationToCsms,
916 Action::NotifySettlement => Direction::StationToCsms,
917 Action::NotifyWebPaymentStarted => Direction::CsmsToStation,
918 Action::OpenPeriodicEventStream => Direction::StationToCsms,
919 Action::PublishFirmware => Direction::CsmsToStation,
920 Action::PublishFirmwareStatusNotification => Direction::StationToCsms,
921 Action::PullDynamicScheduleUpdate => Direction::StationToCsms,
922 Action::ReportChargingProfiles => Direction::StationToCsms,
923 Action::ReportDERControl => Direction::StationToCsms,
924 Action::RequestBatterySwap => Direction::CsmsToStation,
925 Action::RequestStartTransaction => Direction::CsmsToStation,
926 Action::RequestStopTransaction => Direction::CsmsToStation,
927 Action::ReservationStatusUpdate => Direction::StationToCsms,
928 Action::ReserveNow => Direction::CsmsToStation,
929 Action::Reset => Direction::CsmsToStation,
930 Action::SecurityEventNotification => Direction::StationToCsms,
931 Action::SendLocalList => Direction::CsmsToStation,
932 Action::SetChargingProfile => Direction::CsmsToStation,
933 Action::SetDERControl => Direction::CsmsToStation,
934 Action::SetDefaultTariff => Direction::CsmsToStation,
935 Action::SetDisplayMessage => Direction::CsmsToStation,
936 Action::SetMonitoringBase => Direction::CsmsToStation,
937 Action::SetMonitoringLevel => Direction::CsmsToStation,
938 Action::SetNetworkProfile => Direction::CsmsToStation,
939 Action::SetVariableMonitoring => Direction::CsmsToStation,
940 Action::SetVariables => Direction::CsmsToStation,
941 Action::SignCertificate => Direction::StationToCsms,
942 Action::StatusNotification => Direction::StationToCsms,
943 Action::TransactionEvent => Direction::StationToCsms,
944 Action::TriggerMessage => Direction::CsmsToStation,
945 Action::UnlockConnector => Direction::CsmsToStation,
946 Action::UnpublishFirmware => Direction::CsmsToStation,
947 Action::UpdateDynamicSchedule => Direction::CsmsToStation,
948 Action::UpdateFirmware => Direction::CsmsToStation,
949 Action::UsePriorityCharging => Direction::CsmsToStation,
950 Action::VatNumberValidation => Direction::StationToCsms,
951 }
952 }
953
954 pub const fn is_send(&self) -> bool {
956 matches!(self, Action::NotifyPeriodicEventStream)
957 }
958}
959
960impl std::fmt::Display for Action {
961 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
962 f.write_str(self.as_str())
963 }
964}
965
966#[derive(Debug, Clone, PartialEq)]
968pub enum DecodeError {
969 UnknownAction(String),
971 WrongDirection(Action),
973 Invalid(Violation),
975}
976
977impl std::fmt::Display for DecodeError {
978 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
979 match self {
980 DecodeError::UnknownAction(a) => write!(f, "unknown action '{a}'"),
981 DecodeError::WrongDirection(a) => {
982 write!(f, "action '{a}' is not accepted in this direction")
983 }
984 DecodeError::Invalid(v) => write!(f, "{v}"),
985 }
986 }
987}
988
989impl std::error::Error for DecodeError {}
990
991#[derive(Debug, Clone, PartialEq)]
993pub enum StationCall {
994 Authorize(AuthorizeRequest),
995 BatterySwap(BatterySwapRequest),
996 BootNotification(BootNotificationRequest),
997 ClearedChargingLimit(ClearedChargingLimitRequest),
998 ClosePeriodicEventStream(ClosePeriodicEventStreamRequest),
999 DataTransfer(DataTransferRequest),
1000 FirmwareStatusNotification(FirmwareStatusNotificationRequest),
1001 Get15118EVCertificate(Get15118EVCertificateRequest),
1002 GetCertificateChainStatus(GetCertificateChainStatusRequest),
1003 GetCertificateStatus(GetCertificateStatusRequest),
1004 Heartbeat(HeartbeatRequest),
1005 LogStatusNotification(LogStatusNotificationRequest),
1006 MeterValues(MeterValuesRequest),
1007 NotifyChargingLimit(NotifyChargingLimitRequest),
1008 NotifyCustomerInformation(NotifyCustomerInformationRequest),
1009 NotifyDERAlarm(NotifyDERAlarmRequest),
1010 NotifyDERStartStop(NotifyDERStartStopRequest),
1011 NotifyDisplayMessages(NotifyDisplayMessagesRequest),
1012 NotifyEVChargingNeeds(NotifyEVChargingNeedsRequest),
1013 NotifyEVChargingSchedule(NotifyEVChargingScheduleRequest),
1014 NotifyEvent(NotifyEventRequest),
1015 NotifyMonitoringReport(NotifyMonitoringReportRequest),
1016 NotifyPriorityCharging(NotifyPriorityChargingRequest),
1017 NotifyReport(NotifyReportRequest),
1018 NotifySettlement(NotifySettlementRequest),
1019 OpenPeriodicEventStream(OpenPeriodicEventStreamRequest),
1020 PublishFirmwareStatusNotification(PublishFirmwareStatusNotificationRequest),
1021 PullDynamicScheduleUpdate(PullDynamicScheduleUpdateRequest),
1022 ReportChargingProfiles(ReportChargingProfilesRequest),
1023 ReportDERControl(ReportDERControlRequest),
1024 ReservationStatusUpdate(ReservationStatusUpdateRequest),
1025 SecurityEventNotification(SecurityEventNotificationRequest),
1026 SignCertificate(SignCertificateRequest),
1027 StatusNotification(StatusNotificationRequest),
1028 TransactionEvent(TransactionEventRequest),
1029 VatNumberValidation(VatNumberValidationRequest),
1030}
1031
1032impl StationCall {
1033 pub const fn action(&self) -> Action {
1034 match self {
1035 StationCall::Authorize(_) => Action::Authorize,
1036 StationCall::BatterySwap(_) => Action::BatterySwap,
1037 StationCall::BootNotification(_) => Action::BootNotification,
1038 StationCall::ClearedChargingLimit(_) => Action::ClearedChargingLimit,
1039 StationCall::ClosePeriodicEventStream(_) => Action::ClosePeriodicEventStream,
1040 StationCall::DataTransfer(_) => Action::DataTransfer,
1041 StationCall::FirmwareStatusNotification(_) => Action::FirmwareStatusNotification,
1042 StationCall::Get15118EVCertificate(_) => Action::Get15118EVCertificate,
1043 StationCall::GetCertificateChainStatus(_) => Action::GetCertificateChainStatus,
1044 StationCall::GetCertificateStatus(_) => Action::GetCertificateStatus,
1045 StationCall::Heartbeat(_) => Action::Heartbeat,
1046 StationCall::LogStatusNotification(_) => Action::LogStatusNotification,
1047 StationCall::MeterValues(_) => Action::MeterValues,
1048 StationCall::NotifyChargingLimit(_) => Action::NotifyChargingLimit,
1049 StationCall::NotifyCustomerInformation(_) => Action::NotifyCustomerInformation,
1050 StationCall::NotifyDERAlarm(_) => Action::NotifyDERAlarm,
1051 StationCall::NotifyDERStartStop(_) => Action::NotifyDERStartStop,
1052 StationCall::NotifyDisplayMessages(_) => Action::NotifyDisplayMessages,
1053 StationCall::NotifyEVChargingNeeds(_) => Action::NotifyEVChargingNeeds,
1054 StationCall::NotifyEVChargingSchedule(_) => Action::NotifyEVChargingSchedule,
1055 StationCall::NotifyEvent(_) => Action::NotifyEvent,
1056 StationCall::NotifyMonitoringReport(_) => Action::NotifyMonitoringReport,
1057 StationCall::NotifyPriorityCharging(_) => Action::NotifyPriorityCharging,
1058 StationCall::NotifyReport(_) => Action::NotifyReport,
1059 StationCall::NotifySettlement(_) => Action::NotifySettlement,
1060 StationCall::OpenPeriodicEventStream(_) => Action::OpenPeriodicEventStream,
1061 StationCall::PublishFirmwareStatusNotification(_) => {
1062 Action::PublishFirmwareStatusNotification
1063 }
1064 StationCall::PullDynamicScheduleUpdate(_) => Action::PullDynamicScheduleUpdate,
1065 StationCall::ReportChargingProfiles(_) => Action::ReportChargingProfiles,
1066 StationCall::ReportDERControl(_) => Action::ReportDERControl,
1067 StationCall::ReservationStatusUpdate(_) => Action::ReservationStatusUpdate,
1068 StationCall::SecurityEventNotification(_) => Action::SecurityEventNotification,
1069 StationCall::SignCertificate(_) => Action::SignCertificate,
1070 StationCall::StatusNotification(_) => Action::StatusNotification,
1071 StationCall::TransactionEvent(_) => Action::TransactionEvent,
1072 StationCall::VatNumberValidation(_) => Action::VatNumberValidation,
1073 }
1074 }
1075
1076 pub fn decode(action: &str, payload: &str) -> Result<Self, DecodeError> {
1078 let a = Action::from_name(action)
1079 .ok_or_else(|| DecodeError::UnknownAction(action.to_owned()))?;
1080 match a {
1081 Action::Authorize => ocpp_core::decode_payload(payload)
1082 .map(StationCall::Authorize)
1083 .map_err(DecodeError::Invalid),
1084 Action::BatterySwap => ocpp_core::decode_payload(payload)
1085 .map(StationCall::BatterySwap)
1086 .map_err(DecodeError::Invalid),
1087 Action::BootNotification => ocpp_core::decode_payload(payload)
1088 .map(StationCall::BootNotification)
1089 .map_err(DecodeError::Invalid),
1090 Action::ClearedChargingLimit => ocpp_core::decode_payload(payload)
1091 .map(StationCall::ClearedChargingLimit)
1092 .map_err(DecodeError::Invalid),
1093 Action::ClosePeriodicEventStream => ocpp_core::decode_payload(payload)
1094 .map(StationCall::ClosePeriodicEventStream)
1095 .map_err(DecodeError::Invalid),
1096 Action::DataTransfer => ocpp_core::decode_payload(payload)
1097 .map(StationCall::DataTransfer)
1098 .map_err(DecodeError::Invalid),
1099 Action::FirmwareStatusNotification => ocpp_core::decode_payload(payload)
1100 .map(StationCall::FirmwareStatusNotification)
1101 .map_err(DecodeError::Invalid),
1102 Action::Get15118EVCertificate => ocpp_core::decode_payload(payload)
1103 .map(StationCall::Get15118EVCertificate)
1104 .map_err(DecodeError::Invalid),
1105 Action::GetCertificateChainStatus => ocpp_core::decode_payload(payload)
1106 .map(StationCall::GetCertificateChainStatus)
1107 .map_err(DecodeError::Invalid),
1108 Action::GetCertificateStatus => ocpp_core::decode_payload(payload)
1109 .map(StationCall::GetCertificateStatus)
1110 .map_err(DecodeError::Invalid),
1111 Action::Heartbeat => ocpp_core::decode_payload(payload)
1112 .map(StationCall::Heartbeat)
1113 .map_err(DecodeError::Invalid),
1114 Action::LogStatusNotification => ocpp_core::decode_payload(payload)
1115 .map(StationCall::LogStatusNotification)
1116 .map_err(DecodeError::Invalid),
1117 Action::MeterValues => ocpp_core::decode_payload(payload)
1118 .map(StationCall::MeterValues)
1119 .map_err(DecodeError::Invalid),
1120 Action::NotifyChargingLimit => ocpp_core::decode_payload(payload)
1121 .map(StationCall::NotifyChargingLimit)
1122 .map_err(DecodeError::Invalid),
1123 Action::NotifyCustomerInformation => ocpp_core::decode_payload(payload)
1124 .map(StationCall::NotifyCustomerInformation)
1125 .map_err(DecodeError::Invalid),
1126 Action::NotifyDERAlarm => ocpp_core::decode_payload(payload)
1127 .map(StationCall::NotifyDERAlarm)
1128 .map_err(DecodeError::Invalid),
1129 Action::NotifyDERStartStop => ocpp_core::decode_payload(payload)
1130 .map(StationCall::NotifyDERStartStop)
1131 .map_err(DecodeError::Invalid),
1132 Action::NotifyDisplayMessages => ocpp_core::decode_payload(payload)
1133 .map(StationCall::NotifyDisplayMessages)
1134 .map_err(DecodeError::Invalid),
1135 Action::NotifyEVChargingNeeds => ocpp_core::decode_payload(payload)
1136 .map(StationCall::NotifyEVChargingNeeds)
1137 .map_err(DecodeError::Invalid),
1138 Action::NotifyEVChargingSchedule => ocpp_core::decode_payload(payload)
1139 .map(StationCall::NotifyEVChargingSchedule)
1140 .map_err(DecodeError::Invalid),
1141 Action::NotifyEvent => ocpp_core::decode_payload(payload)
1142 .map(StationCall::NotifyEvent)
1143 .map_err(DecodeError::Invalid),
1144 Action::NotifyMonitoringReport => ocpp_core::decode_payload(payload)
1145 .map(StationCall::NotifyMonitoringReport)
1146 .map_err(DecodeError::Invalid),
1147 Action::NotifyPriorityCharging => ocpp_core::decode_payload(payload)
1148 .map(StationCall::NotifyPriorityCharging)
1149 .map_err(DecodeError::Invalid),
1150 Action::NotifyReport => ocpp_core::decode_payload(payload)
1151 .map(StationCall::NotifyReport)
1152 .map_err(DecodeError::Invalid),
1153 Action::NotifySettlement => ocpp_core::decode_payload(payload)
1154 .map(StationCall::NotifySettlement)
1155 .map_err(DecodeError::Invalid),
1156 Action::OpenPeriodicEventStream => ocpp_core::decode_payload(payload)
1157 .map(StationCall::OpenPeriodicEventStream)
1158 .map_err(DecodeError::Invalid),
1159 Action::PublishFirmwareStatusNotification => ocpp_core::decode_payload(payload)
1160 .map(StationCall::PublishFirmwareStatusNotification)
1161 .map_err(DecodeError::Invalid),
1162 Action::PullDynamicScheduleUpdate => ocpp_core::decode_payload(payload)
1163 .map(StationCall::PullDynamicScheduleUpdate)
1164 .map_err(DecodeError::Invalid),
1165 Action::ReportChargingProfiles => ocpp_core::decode_payload(payload)
1166 .map(StationCall::ReportChargingProfiles)
1167 .map_err(DecodeError::Invalid),
1168 Action::ReportDERControl => ocpp_core::decode_payload(payload)
1169 .map(StationCall::ReportDERControl)
1170 .map_err(DecodeError::Invalid),
1171 Action::ReservationStatusUpdate => ocpp_core::decode_payload(payload)
1172 .map(StationCall::ReservationStatusUpdate)
1173 .map_err(DecodeError::Invalid),
1174 Action::SecurityEventNotification => ocpp_core::decode_payload(payload)
1175 .map(StationCall::SecurityEventNotification)
1176 .map_err(DecodeError::Invalid),
1177 Action::SignCertificate => ocpp_core::decode_payload(payload)
1178 .map(StationCall::SignCertificate)
1179 .map_err(DecodeError::Invalid),
1180 Action::StatusNotification => ocpp_core::decode_payload(payload)
1181 .map(StationCall::StatusNotification)
1182 .map_err(DecodeError::Invalid),
1183 Action::TransactionEvent => ocpp_core::decode_payload(payload)
1184 .map(StationCall::TransactionEvent)
1185 .map_err(DecodeError::Invalid),
1186 Action::VatNumberValidation => ocpp_core::decode_payload(payload)
1187 .map(StationCall::VatNumberValidation)
1188 .map_err(DecodeError::Invalid),
1189 #[allow(unreachable_patterns)]
1190 other => Err(DecodeError::WrongDirection(other)),
1191 }
1192 }
1193
1194 pub fn from_value(action: &str, payload: serde_json::Value) -> Result<Self, DecodeError> {
1196 let a = Action::from_name(action)
1197 .ok_or_else(|| DecodeError::UnknownAction(action.to_owned()))?;
1198 match a {
1199 Action::Authorize => ocpp_core::decode_value(payload)
1200 .map(StationCall::Authorize)
1201 .map_err(DecodeError::Invalid),
1202 Action::BatterySwap => ocpp_core::decode_value(payload)
1203 .map(StationCall::BatterySwap)
1204 .map_err(DecodeError::Invalid),
1205 Action::BootNotification => ocpp_core::decode_value(payload)
1206 .map(StationCall::BootNotification)
1207 .map_err(DecodeError::Invalid),
1208 Action::ClearedChargingLimit => ocpp_core::decode_value(payload)
1209 .map(StationCall::ClearedChargingLimit)
1210 .map_err(DecodeError::Invalid),
1211 Action::ClosePeriodicEventStream => ocpp_core::decode_value(payload)
1212 .map(StationCall::ClosePeriodicEventStream)
1213 .map_err(DecodeError::Invalid),
1214 Action::DataTransfer => ocpp_core::decode_value(payload)
1215 .map(StationCall::DataTransfer)
1216 .map_err(DecodeError::Invalid),
1217 Action::FirmwareStatusNotification => ocpp_core::decode_value(payload)
1218 .map(StationCall::FirmwareStatusNotification)
1219 .map_err(DecodeError::Invalid),
1220 Action::Get15118EVCertificate => ocpp_core::decode_value(payload)
1221 .map(StationCall::Get15118EVCertificate)
1222 .map_err(DecodeError::Invalid),
1223 Action::GetCertificateChainStatus => ocpp_core::decode_value(payload)
1224 .map(StationCall::GetCertificateChainStatus)
1225 .map_err(DecodeError::Invalid),
1226 Action::GetCertificateStatus => ocpp_core::decode_value(payload)
1227 .map(StationCall::GetCertificateStatus)
1228 .map_err(DecodeError::Invalid),
1229 Action::Heartbeat => ocpp_core::decode_value(payload)
1230 .map(StationCall::Heartbeat)
1231 .map_err(DecodeError::Invalid),
1232 Action::LogStatusNotification => ocpp_core::decode_value(payload)
1233 .map(StationCall::LogStatusNotification)
1234 .map_err(DecodeError::Invalid),
1235 Action::MeterValues => ocpp_core::decode_value(payload)
1236 .map(StationCall::MeterValues)
1237 .map_err(DecodeError::Invalid),
1238 Action::NotifyChargingLimit => ocpp_core::decode_value(payload)
1239 .map(StationCall::NotifyChargingLimit)
1240 .map_err(DecodeError::Invalid),
1241 Action::NotifyCustomerInformation => ocpp_core::decode_value(payload)
1242 .map(StationCall::NotifyCustomerInformation)
1243 .map_err(DecodeError::Invalid),
1244 Action::NotifyDERAlarm => ocpp_core::decode_value(payload)
1245 .map(StationCall::NotifyDERAlarm)
1246 .map_err(DecodeError::Invalid),
1247 Action::NotifyDERStartStop => ocpp_core::decode_value(payload)
1248 .map(StationCall::NotifyDERStartStop)
1249 .map_err(DecodeError::Invalid),
1250 Action::NotifyDisplayMessages => ocpp_core::decode_value(payload)
1251 .map(StationCall::NotifyDisplayMessages)
1252 .map_err(DecodeError::Invalid),
1253 Action::NotifyEVChargingNeeds => ocpp_core::decode_value(payload)
1254 .map(StationCall::NotifyEVChargingNeeds)
1255 .map_err(DecodeError::Invalid),
1256 Action::NotifyEVChargingSchedule => ocpp_core::decode_value(payload)
1257 .map(StationCall::NotifyEVChargingSchedule)
1258 .map_err(DecodeError::Invalid),
1259 Action::NotifyEvent => ocpp_core::decode_value(payload)
1260 .map(StationCall::NotifyEvent)
1261 .map_err(DecodeError::Invalid),
1262 Action::NotifyMonitoringReport => ocpp_core::decode_value(payload)
1263 .map(StationCall::NotifyMonitoringReport)
1264 .map_err(DecodeError::Invalid),
1265 Action::NotifyPriorityCharging => ocpp_core::decode_value(payload)
1266 .map(StationCall::NotifyPriorityCharging)
1267 .map_err(DecodeError::Invalid),
1268 Action::NotifyReport => ocpp_core::decode_value(payload)
1269 .map(StationCall::NotifyReport)
1270 .map_err(DecodeError::Invalid),
1271 Action::NotifySettlement => ocpp_core::decode_value(payload)
1272 .map(StationCall::NotifySettlement)
1273 .map_err(DecodeError::Invalid),
1274 Action::OpenPeriodicEventStream => ocpp_core::decode_value(payload)
1275 .map(StationCall::OpenPeriodicEventStream)
1276 .map_err(DecodeError::Invalid),
1277 Action::PublishFirmwareStatusNotification => ocpp_core::decode_value(payload)
1278 .map(StationCall::PublishFirmwareStatusNotification)
1279 .map_err(DecodeError::Invalid),
1280 Action::PullDynamicScheduleUpdate => ocpp_core::decode_value(payload)
1281 .map(StationCall::PullDynamicScheduleUpdate)
1282 .map_err(DecodeError::Invalid),
1283 Action::ReportChargingProfiles => ocpp_core::decode_value(payload)
1284 .map(StationCall::ReportChargingProfiles)
1285 .map_err(DecodeError::Invalid),
1286 Action::ReportDERControl => ocpp_core::decode_value(payload)
1287 .map(StationCall::ReportDERControl)
1288 .map_err(DecodeError::Invalid),
1289 Action::ReservationStatusUpdate => ocpp_core::decode_value(payload)
1290 .map(StationCall::ReservationStatusUpdate)
1291 .map_err(DecodeError::Invalid),
1292 Action::SecurityEventNotification => ocpp_core::decode_value(payload)
1293 .map(StationCall::SecurityEventNotification)
1294 .map_err(DecodeError::Invalid),
1295 Action::SignCertificate => ocpp_core::decode_value(payload)
1296 .map(StationCall::SignCertificate)
1297 .map_err(DecodeError::Invalid),
1298 Action::StatusNotification => ocpp_core::decode_value(payload)
1299 .map(StationCall::StatusNotification)
1300 .map_err(DecodeError::Invalid),
1301 Action::TransactionEvent => ocpp_core::decode_value(payload)
1302 .map(StationCall::TransactionEvent)
1303 .map_err(DecodeError::Invalid),
1304 Action::VatNumberValidation => ocpp_core::decode_value(payload)
1305 .map(StationCall::VatNumberValidation)
1306 .map_err(DecodeError::Invalid),
1307 #[allow(unreachable_patterns)]
1308 other => Err(DecodeError::WrongDirection(other)),
1309 }
1310 }
1311
1312 pub fn to_payload(&self) -> serde_json::Value {
1314 match self {
1315 StationCall::Authorize(r) => serde_json::to_value(r).expect("serializable"),
1316 StationCall::BatterySwap(r) => serde_json::to_value(r).expect("serializable"),
1317 StationCall::BootNotification(r) => serde_json::to_value(r).expect("serializable"),
1318 StationCall::ClearedChargingLimit(r) => serde_json::to_value(r).expect("serializable"),
1319 StationCall::ClosePeriodicEventStream(r) => {
1320 serde_json::to_value(r).expect("serializable")
1321 }
1322 StationCall::DataTransfer(r) => serde_json::to_value(r).expect("serializable"),
1323 StationCall::FirmwareStatusNotification(r) => {
1324 serde_json::to_value(r).expect("serializable")
1325 }
1326 StationCall::Get15118EVCertificate(r) => serde_json::to_value(r).expect("serializable"),
1327 StationCall::GetCertificateChainStatus(r) => {
1328 serde_json::to_value(r).expect("serializable")
1329 }
1330 StationCall::GetCertificateStatus(r) => serde_json::to_value(r).expect("serializable"),
1331 StationCall::Heartbeat(r) => serde_json::to_value(r).expect("serializable"),
1332 StationCall::LogStatusNotification(r) => serde_json::to_value(r).expect("serializable"),
1333 StationCall::MeterValues(r) => serde_json::to_value(r).expect("serializable"),
1334 StationCall::NotifyChargingLimit(r) => serde_json::to_value(r).expect("serializable"),
1335 StationCall::NotifyCustomerInformation(r) => {
1336 serde_json::to_value(r).expect("serializable")
1337 }
1338 StationCall::NotifyDERAlarm(r) => serde_json::to_value(r).expect("serializable"),
1339 StationCall::NotifyDERStartStop(r) => serde_json::to_value(r).expect("serializable"),
1340 StationCall::NotifyDisplayMessages(r) => serde_json::to_value(r).expect("serializable"),
1341 StationCall::NotifyEVChargingNeeds(r) => serde_json::to_value(r).expect("serializable"),
1342 StationCall::NotifyEVChargingSchedule(r) => {
1343 serde_json::to_value(r).expect("serializable")
1344 }
1345 StationCall::NotifyEvent(r) => serde_json::to_value(r).expect("serializable"),
1346 StationCall::NotifyMonitoringReport(r) => {
1347 serde_json::to_value(r).expect("serializable")
1348 }
1349 StationCall::NotifyPriorityCharging(r) => {
1350 serde_json::to_value(r).expect("serializable")
1351 }
1352 StationCall::NotifyReport(r) => serde_json::to_value(r).expect("serializable"),
1353 StationCall::NotifySettlement(r) => serde_json::to_value(r).expect("serializable"),
1354 StationCall::OpenPeriodicEventStream(r) => {
1355 serde_json::to_value(r).expect("serializable")
1356 }
1357 StationCall::PublishFirmwareStatusNotification(r) => {
1358 serde_json::to_value(r).expect("serializable")
1359 }
1360 StationCall::PullDynamicScheduleUpdate(r) => {
1361 serde_json::to_value(r).expect("serializable")
1362 }
1363 StationCall::ReportChargingProfiles(r) => {
1364 serde_json::to_value(r).expect("serializable")
1365 }
1366 StationCall::ReportDERControl(r) => serde_json::to_value(r).expect("serializable"),
1367 StationCall::ReservationStatusUpdate(r) => {
1368 serde_json::to_value(r).expect("serializable")
1369 }
1370 StationCall::SecurityEventNotification(r) => {
1371 serde_json::to_value(r).expect("serializable")
1372 }
1373 StationCall::SignCertificate(r) => serde_json::to_value(r).expect("serializable"),
1374 StationCall::StatusNotification(r) => serde_json::to_value(r).expect("serializable"),
1375 StationCall::TransactionEvent(r) => serde_json::to_value(r).expect("serializable"),
1376 StationCall::VatNumberValidation(r) => serde_json::to_value(r).expect("serializable"),
1377 }
1378 }
1379}
1380
1381#[derive(Debug, Clone, PartialEq)]
1383pub enum CsmsCall {
1384 AFRRSignal(AFRRSignalRequest),
1385 AdjustPeriodicEventStream(AdjustPeriodicEventStreamRequest),
1386 CancelReservation(CancelReservationRequest),
1387 CertificateSigned(CertificateSignedRequest),
1388 ChangeAvailability(ChangeAvailabilityRequest),
1389 ChangeTransactionTariff(ChangeTransactionTariffRequest),
1390 ClearCache(ClearCacheRequest),
1391 ClearChargingProfile(ClearChargingProfileRequest),
1392 ClearDERControl(ClearDERControlRequest),
1393 ClearDisplayMessage(ClearDisplayMessageRequest),
1394 ClearTariffs(ClearTariffsRequest),
1395 ClearVariableMonitoring(ClearVariableMonitoringRequest),
1396 CostUpdated(CostUpdatedRequest),
1397 CustomerInformation(CustomerInformationRequest),
1398 DataTransfer(DataTransferRequest),
1399 DeleteCertificate(DeleteCertificateRequest),
1400 GetBaseReport(GetBaseReportRequest),
1401 GetChargingProfiles(GetChargingProfilesRequest),
1402 GetCompositeSchedule(GetCompositeScheduleRequest),
1403 GetDERControl(GetDERControlRequest),
1404 GetDisplayMessages(GetDisplayMessagesRequest),
1405 GetInstalledCertificateIds(GetInstalledCertificateIdsRequest),
1406 GetLocalListVersion(GetLocalListVersionRequest),
1407 GetLog(GetLogRequest),
1408 GetMonitoringReport(GetMonitoringReportRequest),
1409 GetPeriodicEventStream(GetPeriodicEventStreamRequest),
1410 GetReport(GetReportRequest),
1411 GetTariffs(GetTariffsRequest),
1412 GetTransactionStatus(GetTransactionStatusRequest),
1413 GetVariables(GetVariablesRequest),
1414 InstallCertificate(InstallCertificateRequest),
1415 NotifyAllowedEnergyTransfer(NotifyAllowedEnergyTransferRequest),
1416 NotifyWebPaymentStarted(NotifyWebPaymentStartedRequest),
1417 PublishFirmware(PublishFirmwareRequest),
1418 RequestBatterySwap(RequestBatterySwapRequest),
1419 RequestStartTransaction(RequestStartTransactionRequest),
1420 RequestStopTransaction(RequestStopTransactionRequest),
1421 ReserveNow(ReserveNowRequest),
1422 Reset(ResetRequest),
1423 SendLocalList(SendLocalListRequest),
1424 SetChargingProfile(SetChargingProfileRequest),
1425 SetDERControl(SetDERControlRequest),
1426 SetDefaultTariff(SetDefaultTariffRequest),
1427 SetDisplayMessage(SetDisplayMessageRequest),
1428 SetMonitoringBase(SetMonitoringBaseRequest),
1429 SetMonitoringLevel(SetMonitoringLevelRequest),
1430 SetNetworkProfile(SetNetworkProfileRequest),
1431 SetVariableMonitoring(SetVariableMonitoringRequest),
1432 SetVariables(SetVariablesRequest),
1433 TriggerMessage(TriggerMessageRequest),
1434 UnlockConnector(UnlockConnectorRequest),
1435 UnpublishFirmware(UnpublishFirmwareRequest),
1436 UpdateDynamicSchedule(UpdateDynamicScheduleRequest),
1437 UpdateFirmware(UpdateFirmwareRequest),
1438 UsePriorityCharging(UsePriorityChargingRequest),
1439}
1440
1441impl CsmsCall {
1442 pub const fn action(&self) -> Action {
1443 match self {
1444 CsmsCall::AFRRSignal(_) => Action::AFRRSignal,
1445 CsmsCall::AdjustPeriodicEventStream(_) => Action::AdjustPeriodicEventStream,
1446 CsmsCall::CancelReservation(_) => Action::CancelReservation,
1447 CsmsCall::CertificateSigned(_) => Action::CertificateSigned,
1448 CsmsCall::ChangeAvailability(_) => Action::ChangeAvailability,
1449 CsmsCall::ChangeTransactionTariff(_) => Action::ChangeTransactionTariff,
1450 CsmsCall::ClearCache(_) => Action::ClearCache,
1451 CsmsCall::ClearChargingProfile(_) => Action::ClearChargingProfile,
1452 CsmsCall::ClearDERControl(_) => Action::ClearDERControl,
1453 CsmsCall::ClearDisplayMessage(_) => Action::ClearDisplayMessage,
1454 CsmsCall::ClearTariffs(_) => Action::ClearTariffs,
1455 CsmsCall::ClearVariableMonitoring(_) => Action::ClearVariableMonitoring,
1456 CsmsCall::CostUpdated(_) => Action::CostUpdated,
1457 CsmsCall::CustomerInformation(_) => Action::CustomerInformation,
1458 CsmsCall::DataTransfer(_) => Action::DataTransfer,
1459 CsmsCall::DeleteCertificate(_) => Action::DeleteCertificate,
1460 CsmsCall::GetBaseReport(_) => Action::GetBaseReport,
1461 CsmsCall::GetChargingProfiles(_) => Action::GetChargingProfiles,
1462 CsmsCall::GetCompositeSchedule(_) => Action::GetCompositeSchedule,
1463 CsmsCall::GetDERControl(_) => Action::GetDERControl,
1464 CsmsCall::GetDisplayMessages(_) => Action::GetDisplayMessages,
1465 CsmsCall::GetInstalledCertificateIds(_) => Action::GetInstalledCertificateIds,
1466 CsmsCall::GetLocalListVersion(_) => Action::GetLocalListVersion,
1467 CsmsCall::GetLog(_) => Action::GetLog,
1468 CsmsCall::GetMonitoringReport(_) => Action::GetMonitoringReport,
1469 CsmsCall::GetPeriodicEventStream(_) => Action::GetPeriodicEventStream,
1470 CsmsCall::GetReport(_) => Action::GetReport,
1471 CsmsCall::GetTariffs(_) => Action::GetTariffs,
1472 CsmsCall::GetTransactionStatus(_) => Action::GetTransactionStatus,
1473 CsmsCall::GetVariables(_) => Action::GetVariables,
1474 CsmsCall::InstallCertificate(_) => Action::InstallCertificate,
1475 CsmsCall::NotifyAllowedEnergyTransfer(_) => Action::NotifyAllowedEnergyTransfer,
1476 CsmsCall::NotifyWebPaymentStarted(_) => Action::NotifyWebPaymentStarted,
1477 CsmsCall::PublishFirmware(_) => Action::PublishFirmware,
1478 CsmsCall::RequestBatterySwap(_) => Action::RequestBatterySwap,
1479 CsmsCall::RequestStartTransaction(_) => Action::RequestStartTransaction,
1480 CsmsCall::RequestStopTransaction(_) => Action::RequestStopTransaction,
1481 CsmsCall::ReserveNow(_) => Action::ReserveNow,
1482 CsmsCall::Reset(_) => Action::Reset,
1483 CsmsCall::SendLocalList(_) => Action::SendLocalList,
1484 CsmsCall::SetChargingProfile(_) => Action::SetChargingProfile,
1485 CsmsCall::SetDERControl(_) => Action::SetDERControl,
1486 CsmsCall::SetDefaultTariff(_) => Action::SetDefaultTariff,
1487 CsmsCall::SetDisplayMessage(_) => Action::SetDisplayMessage,
1488 CsmsCall::SetMonitoringBase(_) => Action::SetMonitoringBase,
1489 CsmsCall::SetMonitoringLevel(_) => Action::SetMonitoringLevel,
1490 CsmsCall::SetNetworkProfile(_) => Action::SetNetworkProfile,
1491 CsmsCall::SetVariableMonitoring(_) => Action::SetVariableMonitoring,
1492 CsmsCall::SetVariables(_) => Action::SetVariables,
1493 CsmsCall::TriggerMessage(_) => Action::TriggerMessage,
1494 CsmsCall::UnlockConnector(_) => Action::UnlockConnector,
1495 CsmsCall::UnpublishFirmware(_) => Action::UnpublishFirmware,
1496 CsmsCall::UpdateDynamicSchedule(_) => Action::UpdateDynamicSchedule,
1497 CsmsCall::UpdateFirmware(_) => Action::UpdateFirmware,
1498 CsmsCall::UsePriorityCharging(_) => Action::UsePriorityCharging,
1499 }
1500 }
1501
1502 pub fn decode(action: &str, payload: &str) -> Result<Self, DecodeError> {
1504 let a = Action::from_name(action)
1505 .ok_or_else(|| DecodeError::UnknownAction(action.to_owned()))?;
1506 match a {
1507 Action::AFRRSignal => ocpp_core::decode_payload(payload)
1508 .map(CsmsCall::AFRRSignal)
1509 .map_err(DecodeError::Invalid),
1510 Action::AdjustPeriodicEventStream => ocpp_core::decode_payload(payload)
1511 .map(CsmsCall::AdjustPeriodicEventStream)
1512 .map_err(DecodeError::Invalid),
1513 Action::CancelReservation => ocpp_core::decode_payload(payload)
1514 .map(CsmsCall::CancelReservation)
1515 .map_err(DecodeError::Invalid),
1516 Action::CertificateSigned => ocpp_core::decode_payload(payload)
1517 .map(CsmsCall::CertificateSigned)
1518 .map_err(DecodeError::Invalid),
1519 Action::ChangeAvailability => ocpp_core::decode_payload(payload)
1520 .map(CsmsCall::ChangeAvailability)
1521 .map_err(DecodeError::Invalid),
1522 Action::ChangeTransactionTariff => ocpp_core::decode_payload(payload)
1523 .map(CsmsCall::ChangeTransactionTariff)
1524 .map_err(DecodeError::Invalid),
1525 Action::ClearCache => ocpp_core::decode_payload(payload)
1526 .map(CsmsCall::ClearCache)
1527 .map_err(DecodeError::Invalid),
1528 Action::ClearChargingProfile => ocpp_core::decode_payload(payload)
1529 .map(CsmsCall::ClearChargingProfile)
1530 .map_err(DecodeError::Invalid),
1531 Action::ClearDERControl => ocpp_core::decode_payload(payload)
1532 .map(CsmsCall::ClearDERControl)
1533 .map_err(DecodeError::Invalid),
1534 Action::ClearDisplayMessage => ocpp_core::decode_payload(payload)
1535 .map(CsmsCall::ClearDisplayMessage)
1536 .map_err(DecodeError::Invalid),
1537 Action::ClearTariffs => ocpp_core::decode_payload(payload)
1538 .map(CsmsCall::ClearTariffs)
1539 .map_err(DecodeError::Invalid),
1540 Action::ClearVariableMonitoring => ocpp_core::decode_payload(payload)
1541 .map(CsmsCall::ClearVariableMonitoring)
1542 .map_err(DecodeError::Invalid),
1543 Action::CostUpdated => ocpp_core::decode_payload(payload)
1544 .map(CsmsCall::CostUpdated)
1545 .map_err(DecodeError::Invalid),
1546 Action::CustomerInformation => ocpp_core::decode_payload(payload)
1547 .map(CsmsCall::CustomerInformation)
1548 .map_err(DecodeError::Invalid),
1549 Action::DataTransfer => ocpp_core::decode_payload(payload)
1550 .map(CsmsCall::DataTransfer)
1551 .map_err(DecodeError::Invalid),
1552 Action::DeleteCertificate => ocpp_core::decode_payload(payload)
1553 .map(CsmsCall::DeleteCertificate)
1554 .map_err(DecodeError::Invalid),
1555 Action::GetBaseReport => ocpp_core::decode_payload(payload)
1556 .map(CsmsCall::GetBaseReport)
1557 .map_err(DecodeError::Invalid),
1558 Action::GetChargingProfiles => ocpp_core::decode_payload(payload)
1559 .map(CsmsCall::GetChargingProfiles)
1560 .map_err(DecodeError::Invalid),
1561 Action::GetCompositeSchedule => ocpp_core::decode_payload(payload)
1562 .map(CsmsCall::GetCompositeSchedule)
1563 .map_err(DecodeError::Invalid),
1564 Action::GetDERControl => ocpp_core::decode_payload(payload)
1565 .map(CsmsCall::GetDERControl)
1566 .map_err(DecodeError::Invalid),
1567 Action::GetDisplayMessages => ocpp_core::decode_payload(payload)
1568 .map(CsmsCall::GetDisplayMessages)
1569 .map_err(DecodeError::Invalid),
1570 Action::GetInstalledCertificateIds => ocpp_core::decode_payload(payload)
1571 .map(CsmsCall::GetInstalledCertificateIds)
1572 .map_err(DecodeError::Invalid),
1573 Action::GetLocalListVersion => ocpp_core::decode_payload(payload)
1574 .map(CsmsCall::GetLocalListVersion)
1575 .map_err(DecodeError::Invalid),
1576 Action::GetLog => ocpp_core::decode_payload(payload)
1577 .map(CsmsCall::GetLog)
1578 .map_err(DecodeError::Invalid),
1579 Action::GetMonitoringReport => ocpp_core::decode_payload(payload)
1580 .map(CsmsCall::GetMonitoringReport)
1581 .map_err(DecodeError::Invalid),
1582 Action::GetPeriodicEventStream => ocpp_core::decode_payload(payload)
1583 .map(CsmsCall::GetPeriodicEventStream)
1584 .map_err(DecodeError::Invalid),
1585 Action::GetReport => ocpp_core::decode_payload(payload)
1586 .map(CsmsCall::GetReport)
1587 .map_err(DecodeError::Invalid),
1588 Action::GetTariffs => ocpp_core::decode_payload(payload)
1589 .map(CsmsCall::GetTariffs)
1590 .map_err(DecodeError::Invalid),
1591 Action::GetTransactionStatus => ocpp_core::decode_payload(payload)
1592 .map(CsmsCall::GetTransactionStatus)
1593 .map_err(DecodeError::Invalid),
1594 Action::GetVariables => ocpp_core::decode_payload(payload)
1595 .map(CsmsCall::GetVariables)
1596 .map_err(DecodeError::Invalid),
1597 Action::InstallCertificate => ocpp_core::decode_payload(payload)
1598 .map(CsmsCall::InstallCertificate)
1599 .map_err(DecodeError::Invalid),
1600 Action::NotifyAllowedEnergyTransfer => ocpp_core::decode_payload(payload)
1601 .map(CsmsCall::NotifyAllowedEnergyTransfer)
1602 .map_err(DecodeError::Invalid),
1603 Action::NotifyWebPaymentStarted => ocpp_core::decode_payload(payload)
1604 .map(CsmsCall::NotifyWebPaymentStarted)
1605 .map_err(DecodeError::Invalid),
1606 Action::PublishFirmware => ocpp_core::decode_payload(payload)
1607 .map(CsmsCall::PublishFirmware)
1608 .map_err(DecodeError::Invalid),
1609 Action::RequestBatterySwap => ocpp_core::decode_payload(payload)
1610 .map(CsmsCall::RequestBatterySwap)
1611 .map_err(DecodeError::Invalid),
1612 Action::RequestStartTransaction => ocpp_core::decode_payload(payload)
1613 .map(CsmsCall::RequestStartTransaction)
1614 .map_err(DecodeError::Invalid),
1615 Action::RequestStopTransaction => ocpp_core::decode_payload(payload)
1616 .map(CsmsCall::RequestStopTransaction)
1617 .map_err(DecodeError::Invalid),
1618 Action::ReserveNow => ocpp_core::decode_payload(payload)
1619 .map(CsmsCall::ReserveNow)
1620 .map_err(DecodeError::Invalid),
1621 Action::Reset => ocpp_core::decode_payload(payload)
1622 .map(CsmsCall::Reset)
1623 .map_err(DecodeError::Invalid),
1624 Action::SendLocalList => ocpp_core::decode_payload(payload)
1625 .map(CsmsCall::SendLocalList)
1626 .map_err(DecodeError::Invalid),
1627 Action::SetChargingProfile => ocpp_core::decode_payload(payload)
1628 .map(CsmsCall::SetChargingProfile)
1629 .map_err(DecodeError::Invalid),
1630 Action::SetDERControl => ocpp_core::decode_payload(payload)
1631 .map(CsmsCall::SetDERControl)
1632 .map_err(DecodeError::Invalid),
1633 Action::SetDefaultTariff => ocpp_core::decode_payload(payload)
1634 .map(CsmsCall::SetDefaultTariff)
1635 .map_err(DecodeError::Invalid),
1636 Action::SetDisplayMessage => ocpp_core::decode_payload(payload)
1637 .map(CsmsCall::SetDisplayMessage)
1638 .map_err(DecodeError::Invalid),
1639 Action::SetMonitoringBase => ocpp_core::decode_payload(payload)
1640 .map(CsmsCall::SetMonitoringBase)
1641 .map_err(DecodeError::Invalid),
1642 Action::SetMonitoringLevel => ocpp_core::decode_payload(payload)
1643 .map(CsmsCall::SetMonitoringLevel)
1644 .map_err(DecodeError::Invalid),
1645 Action::SetNetworkProfile => ocpp_core::decode_payload(payload)
1646 .map(CsmsCall::SetNetworkProfile)
1647 .map_err(DecodeError::Invalid),
1648 Action::SetVariableMonitoring => ocpp_core::decode_payload(payload)
1649 .map(CsmsCall::SetVariableMonitoring)
1650 .map_err(DecodeError::Invalid),
1651 Action::SetVariables => ocpp_core::decode_payload(payload)
1652 .map(CsmsCall::SetVariables)
1653 .map_err(DecodeError::Invalid),
1654 Action::TriggerMessage => ocpp_core::decode_payload(payload)
1655 .map(CsmsCall::TriggerMessage)
1656 .map_err(DecodeError::Invalid),
1657 Action::UnlockConnector => ocpp_core::decode_payload(payload)
1658 .map(CsmsCall::UnlockConnector)
1659 .map_err(DecodeError::Invalid),
1660 Action::UnpublishFirmware => ocpp_core::decode_payload(payload)
1661 .map(CsmsCall::UnpublishFirmware)
1662 .map_err(DecodeError::Invalid),
1663 Action::UpdateDynamicSchedule => ocpp_core::decode_payload(payload)
1664 .map(CsmsCall::UpdateDynamicSchedule)
1665 .map_err(DecodeError::Invalid),
1666 Action::UpdateFirmware => ocpp_core::decode_payload(payload)
1667 .map(CsmsCall::UpdateFirmware)
1668 .map_err(DecodeError::Invalid),
1669 Action::UsePriorityCharging => ocpp_core::decode_payload(payload)
1670 .map(CsmsCall::UsePriorityCharging)
1671 .map_err(DecodeError::Invalid),
1672 #[allow(unreachable_patterns)]
1673 other => Err(DecodeError::WrongDirection(other)),
1674 }
1675 }
1676
1677 pub fn from_value(action: &str, payload: serde_json::Value) -> Result<Self, DecodeError> {
1679 let a = Action::from_name(action)
1680 .ok_or_else(|| DecodeError::UnknownAction(action.to_owned()))?;
1681 match a {
1682 Action::AFRRSignal => ocpp_core::decode_value(payload)
1683 .map(CsmsCall::AFRRSignal)
1684 .map_err(DecodeError::Invalid),
1685 Action::AdjustPeriodicEventStream => ocpp_core::decode_value(payload)
1686 .map(CsmsCall::AdjustPeriodicEventStream)
1687 .map_err(DecodeError::Invalid),
1688 Action::CancelReservation => ocpp_core::decode_value(payload)
1689 .map(CsmsCall::CancelReservation)
1690 .map_err(DecodeError::Invalid),
1691 Action::CertificateSigned => ocpp_core::decode_value(payload)
1692 .map(CsmsCall::CertificateSigned)
1693 .map_err(DecodeError::Invalid),
1694 Action::ChangeAvailability => ocpp_core::decode_value(payload)
1695 .map(CsmsCall::ChangeAvailability)
1696 .map_err(DecodeError::Invalid),
1697 Action::ChangeTransactionTariff => ocpp_core::decode_value(payload)
1698 .map(CsmsCall::ChangeTransactionTariff)
1699 .map_err(DecodeError::Invalid),
1700 Action::ClearCache => ocpp_core::decode_value(payload)
1701 .map(CsmsCall::ClearCache)
1702 .map_err(DecodeError::Invalid),
1703 Action::ClearChargingProfile => ocpp_core::decode_value(payload)
1704 .map(CsmsCall::ClearChargingProfile)
1705 .map_err(DecodeError::Invalid),
1706 Action::ClearDERControl => ocpp_core::decode_value(payload)
1707 .map(CsmsCall::ClearDERControl)
1708 .map_err(DecodeError::Invalid),
1709 Action::ClearDisplayMessage => ocpp_core::decode_value(payload)
1710 .map(CsmsCall::ClearDisplayMessage)
1711 .map_err(DecodeError::Invalid),
1712 Action::ClearTariffs => ocpp_core::decode_value(payload)
1713 .map(CsmsCall::ClearTariffs)
1714 .map_err(DecodeError::Invalid),
1715 Action::ClearVariableMonitoring => ocpp_core::decode_value(payload)
1716 .map(CsmsCall::ClearVariableMonitoring)
1717 .map_err(DecodeError::Invalid),
1718 Action::CostUpdated => ocpp_core::decode_value(payload)
1719 .map(CsmsCall::CostUpdated)
1720 .map_err(DecodeError::Invalid),
1721 Action::CustomerInformation => ocpp_core::decode_value(payload)
1722 .map(CsmsCall::CustomerInformation)
1723 .map_err(DecodeError::Invalid),
1724 Action::DataTransfer => ocpp_core::decode_value(payload)
1725 .map(CsmsCall::DataTransfer)
1726 .map_err(DecodeError::Invalid),
1727 Action::DeleteCertificate => ocpp_core::decode_value(payload)
1728 .map(CsmsCall::DeleteCertificate)
1729 .map_err(DecodeError::Invalid),
1730 Action::GetBaseReport => ocpp_core::decode_value(payload)
1731 .map(CsmsCall::GetBaseReport)
1732 .map_err(DecodeError::Invalid),
1733 Action::GetChargingProfiles => ocpp_core::decode_value(payload)
1734 .map(CsmsCall::GetChargingProfiles)
1735 .map_err(DecodeError::Invalid),
1736 Action::GetCompositeSchedule => ocpp_core::decode_value(payload)
1737 .map(CsmsCall::GetCompositeSchedule)
1738 .map_err(DecodeError::Invalid),
1739 Action::GetDERControl => ocpp_core::decode_value(payload)
1740 .map(CsmsCall::GetDERControl)
1741 .map_err(DecodeError::Invalid),
1742 Action::GetDisplayMessages => ocpp_core::decode_value(payload)
1743 .map(CsmsCall::GetDisplayMessages)
1744 .map_err(DecodeError::Invalid),
1745 Action::GetInstalledCertificateIds => ocpp_core::decode_value(payload)
1746 .map(CsmsCall::GetInstalledCertificateIds)
1747 .map_err(DecodeError::Invalid),
1748 Action::GetLocalListVersion => ocpp_core::decode_value(payload)
1749 .map(CsmsCall::GetLocalListVersion)
1750 .map_err(DecodeError::Invalid),
1751 Action::GetLog => ocpp_core::decode_value(payload)
1752 .map(CsmsCall::GetLog)
1753 .map_err(DecodeError::Invalid),
1754 Action::GetMonitoringReport => ocpp_core::decode_value(payload)
1755 .map(CsmsCall::GetMonitoringReport)
1756 .map_err(DecodeError::Invalid),
1757 Action::GetPeriodicEventStream => ocpp_core::decode_value(payload)
1758 .map(CsmsCall::GetPeriodicEventStream)
1759 .map_err(DecodeError::Invalid),
1760 Action::GetReport => ocpp_core::decode_value(payload)
1761 .map(CsmsCall::GetReport)
1762 .map_err(DecodeError::Invalid),
1763 Action::GetTariffs => ocpp_core::decode_value(payload)
1764 .map(CsmsCall::GetTariffs)
1765 .map_err(DecodeError::Invalid),
1766 Action::GetTransactionStatus => ocpp_core::decode_value(payload)
1767 .map(CsmsCall::GetTransactionStatus)
1768 .map_err(DecodeError::Invalid),
1769 Action::GetVariables => ocpp_core::decode_value(payload)
1770 .map(CsmsCall::GetVariables)
1771 .map_err(DecodeError::Invalid),
1772 Action::InstallCertificate => ocpp_core::decode_value(payload)
1773 .map(CsmsCall::InstallCertificate)
1774 .map_err(DecodeError::Invalid),
1775 Action::NotifyAllowedEnergyTransfer => ocpp_core::decode_value(payload)
1776 .map(CsmsCall::NotifyAllowedEnergyTransfer)
1777 .map_err(DecodeError::Invalid),
1778 Action::NotifyWebPaymentStarted => ocpp_core::decode_value(payload)
1779 .map(CsmsCall::NotifyWebPaymentStarted)
1780 .map_err(DecodeError::Invalid),
1781 Action::PublishFirmware => ocpp_core::decode_value(payload)
1782 .map(CsmsCall::PublishFirmware)
1783 .map_err(DecodeError::Invalid),
1784 Action::RequestBatterySwap => ocpp_core::decode_value(payload)
1785 .map(CsmsCall::RequestBatterySwap)
1786 .map_err(DecodeError::Invalid),
1787 Action::RequestStartTransaction => ocpp_core::decode_value(payload)
1788 .map(CsmsCall::RequestStartTransaction)
1789 .map_err(DecodeError::Invalid),
1790 Action::RequestStopTransaction => ocpp_core::decode_value(payload)
1791 .map(CsmsCall::RequestStopTransaction)
1792 .map_err(DecodeError::Invalid),
1793 Action::ReserveNow => ocpp_core::decode_value(payload)
1794 .map(CsmsCall::ReserveNow)
1795 .map_err(DecodeError::Invalid),
1796 Action::Reset => ocpp_core::decode_value(payload)
1797 .map(CsmsCall::Reset)
1798 .map_err(DecodeError::Invalid),
1799 Action::SendLocalList => ocpp_core::decode_value(payload)
1800 .map(CsmsCall::SendLocalList)
1801 .map_err(DecodeError::Invalid),
1802 Action::SetChargingProfile => ocpp_core::decode_value(payload)
1803 .map(CsmsCall::SetChargingProfile)
1804 .map_err(DecodeError::Invalid),
1805 Action::SetDERControl => ocpp_core::decode_value(payload)
1806 .map(CsmsCall::SetDERControl)
1807 .map_err(DecodeError::Invalid),
1808 Action::SetDefaultTariff => ocpp_core::decode_value(payload)
1809 .map(CsmsCall::SetDefaultTariff)
1810 .map_err(DecodeError::Invalid),
1811 Action::SetDisplayMessage => ocpp_core::decode_value(payload)
1812 .map(CsmsCall::SetDisplayMessage)
1813 .map_err(DecodeError::Invalid),
1814 Action::SetMonitoringBase => ocpp_core::decode_value(payload)
1815 .map(CsmsCall::SetMonitoringBase)
1816 .map_err(DecodeError::Invalid),
1817 Action::SetMonitoringLevel => ocpp_core::decode_value(payload)
1818 .map(CsmsCall::SetMonitoringLevel)
1819 .map_err(DecodeError::Invalid),
1820 Action::SetNetworkProfile => ocpp_core::decode_value(payload)
1821 .map(CsmsCall::SetNetworkProfile)
1822 .map_err(DecodeError::Invalid),
1823 Action::SetVariableMonitoring => ocpp_core::decode_value(payload)
1824 .map(CsmsCall::SetVariableMonitoring)
1825 .map_err(DecodeError::Invalid),
1826 Action::SetVariables => ocpp_core::decode_value(payload)
1827 .map(CsmsCall::SetVariables)
1828 .map_err(DecodeError::Invalid),
1829 Action::TriggerMessage => ocpp_core::decode_value(payload)
1830 .map(CsmsCall::TriggerMessage)
1831 .map_err(DecodeError::Invalid),
1832 Action::UnlockConnector => ocpp_core::decode_value(payload)
1833 .map(CsmsCall::UnlockConnector)
1834 .map_err(DecodeError::Invalid),
1835 Action::UnpublishFirmware => ocpp_core::decode_value(payload)
1836 .map(CsmsCall::UnpublishFirmware)
1837 .map_err(DecodeError::Invalid),
1838 Action::UpdateDynamicSchedule => ocpp_core::decode_value(payload)
1839 .map(CsmsCall::UpdateDynamicSchedule)
1840 .map_err(DecodeError::Invalid),
1841 Action::UpdateFirmware => ocpp_core::decode_value(payload)
1842 .map(CsmsCall::UpdateFirmware)
1843 .map_err(DecodeError::Invalid),
1844 Action::UsePriorityCharging => ocpp_core::decode_value(payload)
1845 .map(CsmsCall::UsePriorityCharging)
1846 .map_err(DecodeError::Invalid),
1847 #[allow(unreachable_patterns)]
1848 other => Err(DecodeError::WrongDirection(other)),
1849 }
1850 }
1851
1852 pub fn to_payload(&self) -> serde_json::Value {
1854 match self {
1855 CsmsCall::AFRRSignal(r) => serde_json::to_value(r).expect("serializable"),
1856 CsmsCall::AdjustPeriodicEventStream(r) => {
1857 serde_json::to_value(r).expect("serializable")
1858 }
1859 CsmsCall::CancelReservation(r) => serde_json::to_value(r).expect("serializable"),
1860 CsmsCall::CertificateSigned(r) => serde_json::to_value(r).expect("serializable"),
1861 CsmsCall::ChangeAvailability(r) => serde_json::to_value(r).expect("serializable"),
1862 CsmsCall::ChangeTransactionTariff(r) => serde_json::to_value(r).expect("serializable"),
1863 CsmsCall::ClearCache(r) => serde_json::to_value(r).expect("serializable"),
1864 CsmsCall::ClearChargingProfile(r) => serde_json::to_value(r).expect("serializable"),
1865 CsmsCall::ClearDERControl(r) => serde_json::to_value(r).expect("serializable"),
1866 CsmsCall::ClearDisplayMessage(r) => serde_json::to_value(r).expect("serializable"),
1867 CsmsCall::ClearTariffs(r) => serde_json::to_value(r).expect("serializable"),
1868 CsmsCall::ClearVariableMonitoring(r) => serde_json::to_value(r).expect("serializable"),
1869 CsmsCall::CostUpdated(r) => serde_json::to_value(r).expect("serializable"),
1870 CsmsCall::CustomerInformation(r) => serde_json::to_value(r).expect("serializable"),
1871 CsmsCall::DataTransfer(r) => serde_json::to_value(r).expect("serializable"),
1872 CsmsCall::DeleteCertificate(r) => serde_json::to_value(r).expect("serializable"),
1873 CsmsCall::GetBaseReport(r) => serde_json::to_value(r).expect("serializable"),
1874 CsmsCall::GetChargingProfiles(r) => serde_json::to_value(r).expect("serializable"),
1875 CsmsCall::GetCompositeSchedule(r) => serde_json::to_value(r).expect("serializable"),
1876 CsmsCall::GetDERControl(r) => serde_json::to_value(r).expect("serializable"),
1877 CsmsCall::GetDisplayMessages(r) => serde_json::to_value(r).expect("serializable"),
1878 CsmsCall::GetInstalledCertificateIds(r) => {
1879 serde_json::to_value(r).expect("serializable")
1880 }
1881 CsmsCall::GetLocalListVersion(r) => serde_json::to_value(r).expect("serializable"),
1882 CsmsCall::GetLog(r) => serde_json::to_value(r).expect("serializable"),
1883 CsmsCall::GetMonitoringReport(r) => serde_json::to_value(r).expect("serializable"),
1884 CsmsCall::GetPeriodicEventStream(r) => serde_json::to_value(r).expect("serializable"),
1885 CsmsCall::GetReport(r) => serde_json::to_value(r).expect("serializable"),
1886 CsmsCall::GetTariffs(r) => serde_json::to_value(r).expect("serializable"),
1887 CsmsCall::GetTransactionStatus(r) => serde_json::to_value(r).expect("serializable"),
1888 CsmsCall::GetVariables(r) => serde_json::to_value(r).expect("serializable"),
1889 CsmsCall::InstallCertificate(r) => serde_json::to_value(r).expect("serializable"),
1890 CsmsCall::NotifyAllowedEnergyTransfer(r) => {
1891 serde_json::to_value(r).expect("serializable")
1892 }
1893 CsmsCall::NotifyWebPaymentStarted(r) => serde_json::to_value(r).expect("serializable"),
1894 CsmsCall::PublishFirmware(r) => serde_json::to_value(r).expect("serializable"),
1895 CsmsCall::RequestBatterySwap(r) => serde_json::to_value(r).expect("serializable"),
1896 CsmsCall::RequestStartTransaction(r) => serde_json::to_value(r).expect("serializable"),
1897 CsmsCall::RequestStopTransaction(r) => serde_json::to_value(r).expect("serializable"),
1898 CsmsCall::ReserveNow(r) => serde_json::to_value(r).expect("serializable"),
1899 CsmsCall::Reset(r) => serde_json::to_value(r).expect("serializable"),
1900 CsmsCall::SendLocalList(r) => serde_json::to_value(r).expect("serializable"),
1901 CsmsCall::SetChargingProfile(r) => serde_json::to_value(r).expect("serializable"),
1902 CsmsCall::SetDERControl(r) => serde_json::to_value(r).expect("serializable"),
1903 CsmsCall::SetDefaultTariff(r) => serde_json::to_value(r).expect("serializable"),
1904 CsmsCall::SetDisplayMessage(r) => serde_json::to_value(r).expect("serializable"),
1905 CsmsCall::SetMonitoringBase(r) => serde_json::to_value(r).expect("serializable"),
1906 CsmsCall::SetMonitoringLevel(r) => serde_json::to_value(r).expect("serializable"),
1907 CsmsCall::SetNetworkProfile(r) => serde_json::to_value(r).expect("serializable"),
1908 CsmsCall::SetVariableMonitoring(r) => serde_json::to_value(r).expect("serializable"),
1909 CsmsCall::SetVariables(r) => serde_json::to_value(r).expect("serializable"),
1910 CsmsCall::TriggerMessage(r) => serde_json::to_value(r).expect("serializable"),
1911 CsmsCall::UnlockConnector(r) => serde_json::to_value(r).expect("serializable"),
1912 CsmsCall::UnpublishFirmware(r) => serde_json::to_value(r).expect("serializable"),
1913 CsmsCall::UpdateDynamicSchedule(r) => serde_json::to_value(r).expect("serializable"),
1914 CsmsCall::UpdateFirmware(r) => serde_json::to_value(r).expect("serializable"),
1915 CsmsCall::UsePriorityCharging(r) => serde_json::to_value(r).expect("serializable"),
1916 }
1917 }
1918}
1919
1920#[derive(Debug, Clone, PartialEq)]
1922pub enum StationSend {
1923 NotifyPeriodicEventStream(NotifyPeriodicEventStream),
1924}
1925
1926impl StationSend {
1927 pub fn decode(action: &str, payload: &str) -> Result<Self, DecodeError> {
1928 let a = Action::from_name(action)
1929 .ok_or_else(|| DecodeError::UnknownAction(action.to_owned()))?;
1930 match a {
1931 Action::NotifyPeriodicEventStream => ocpp_core::decode_payload(payload)
1932 .map(StationSend::NotifyPeriodicEventStream)
1933 .map_err(DecodeError::Invalid),
1934 other => Err(DecodeError::WrongDirection(other)),
1935 }
1936 }
1937}
1938
1939pub fn validate_response(action: Action, payload: &str) -> Result<serde_json::Value, Violation> {
1941 match action {
1942 Action::AFRRSignal => ocpp_core::decode_payload::<AFRRSignalResponse>(payload)
1943 .map(|r| serde_json::to_value(r).expect("serializable")),
1944 Action::AdjustPeriodicEventStream => {
1945 ocpp_core::decode_payload::<AdjustPeriodicEventStreamResponse>(payload)
1946 .map(|r| serde_json::to_value(r).expect("serializable"))
1947 }
1948 Action::Authorize => ocpp_core::decode_payload::<AuthorizeResponse>(payload)
1949 .map(|r| serde_json::to_value(r).expect("serializable")),
1950 Action::BatterySwap => ocpp_core::decode_payload::<BatterySwapResponse>(payload)
1951 .map(|r| serde_json::to_value(r).expect("serializable")),
1952 Action::BootNotification => ocpp_core::decode_payload::<BootNotificationResponse>(payload)
1953 .map(|r| serde_json::to_value(r).expect("serializable")),
1954 Action::CancelReservation => {
1955 ocpp_core::decode_payload::<CancelReservationResponse>(payload)
1956 .map(|r| serde_json::to_value(r).expect("serializable"))
1957 }
1958 Action::CertificateSigned => {
1959 ocpp_core::decode_payload::<CertificateSignedResponse>(payload)
1960 .map(|r| serde_json::to_value(r).expect("serializable"))
1961 }
1962 Action::ChangeAvailability => {
1963 ocpp_core::decode_payload::<ChangeAvailabilityResponse>(payload)
1964 .map(|r| serde_json::to_value(r).expect("serializable"))
1965 }
1966 Action::ChangeTransactionTariff => {
1967 ocpp_core::decode_payload::<ChangeTransactionTariffResponse>(payload)
1968 .map(|r| serde_json::to_value(r).expect("serializable"))
1969 }
1970 Action::ClearCache => ocpp_core::decode_payload::<ClearCacheResponse>(payload)
1971 .map(|r| serde_json::to_value(r).expect("serializable")),
1972 Action::ClearChargingProfile => {
1973 ocpp_core::decode_payload::<ClearChargingProfileResponse>(payload)
1974 .map(|r| serde_json::to_value(r).expect("serializable"))
1975 }
1976 Action::ClearDERControl => ocpp_core::decode_payload::<ClearDERControlResponse>(payload)
1977 .map(|r| serde_json::to_value(r).expect("serializable")),
1978 Action::ClearDisplayMessage => {
1979 ocpp_core::decode_payload::<ClearDisplayMessageResponse>(payload)
1980 .map(|r| serde_json::to_value(r).expect("serializable"))
1981 }
1982 Action::ClearTariffs => ocpp_core::decode_payload::<ClearTariffsResponse>(payload)
1983 .map(|r| serde_json::to_value(r).expect("serializable")),
1984 Action::ClearVariableMonitoring => {
1985 ocpp_core::decode_payload::<ClearVariableMonitoringResponse>(payload)
1986 .map(|r| serde_json::to_value(r).expect("serializable"))
1987 }
1988 Action::ClearedChargingLimit => {
1989 ocpp_core::decode_payload::<ClearedChargingLimitResponse>(payload)
1990 .map(|r| serde_json::to_value(r).expect("serializable"))
1991 }
1992 Action::ClosePeriodicEventStream => {
1993 ocpp_core::decode_payload::<ClosePeriodicEventStreamResponse>(payload)
1994 .map(|r| serde_json::to_value(r).expect("serializable"))
1995 }
1996 Action::CostUpdated => ocpp_core::decode_payload::<CostUpdatedResponse>(payload)
1997 .map(|r| serde_json::to_value(r).expect("serializable")),
1998 Action::CustomerInformation => {
1999 ocpp_core::decode_payload::<CustomerInformationResponse>(payload)
2000 .map(|r| serde_json::to_value(r).expect("serializable"))
2001 }
2002 Action::DataTransfer => ocpp_core::decode_payload::<DataTransferResponse>(payload)
2003 .map(|r| serde_json::to_value(r).expect("serializable")),
2004 Action::DeleteCertificate => {
2005 ocpp_core::decode_payload::<DeleteCertificateResponse>(payload)
2006 .map(|r| serde_json::to_value(r).expect("serializable"))
2007 }
2008 Action::FirmwareStatusNotification => {
2009 ocpp_core::decode_payload::<FirmwareStatusNotificationResponse>(payload)
2010 .map(|r| serde_json::to_value(r).expect("serializable"))
2011 }
2012 Action::Get15118EVCertificate => {
2013 ocpp_core::decode_payload::<Get15118EVCertificateResponse>(payload)
2014 .map(|r| serde_json::to_value(r).expect("serializable"))
2015 }
2016 Action::GetBaseReport => ocpp_core::decode_payload::<GetBaseReportResponse>(payload)
2017 .map(|r| serde_json::to_value(r).expect("serializable")),
2018 Action::GetCertificateChainStatus => {
2019 ocpp_core::decode_payload::<GetCertificateChainStatusResponse>(payload)
2020 .map(|r| serde_json::to_value(r).expect("serializable"))
2021 }
2022 Action::GetCertificateStatus => {
2023 ocpp_core::decode_payload::<GetCertificateStatusResponse>(payload)
2024 .map(|r| serde_json::to_value(r).expect("serializable"))
2025 }
2026 Action::GetChargingProfiles => {
2027 ocpp_core::decode_payload::<GetChargingProfilesResponse>(payload)
2028 .map(|r| serde_json::to_value(r).expect("serializable"))
2029 }
2030 Action::GetCompositeSchedule => {
2031 ocpp_core::decode_payload::<GetCompositeScheduleResponse>(payload)
2032 .map(|r| serde_json::to_value(r).expect("serializable"))
2033 }
2034 Action::GetDERControl => ocpp_core::decode_payload::<GetDERControlResponse>(payload)
2035 .map(|r| serde_json::to_value(r).expect("serializable")),
2036 Action::GetDisplayMessages => {
2037 ocpp_core::decode_payload::<GetDisplayMessagesResponse>(payload)
2038 .map(|r| serde_json::to_value(r).expect("serializable"))
2039 }
2040 Action::GetInstalledCertificateIds => {
2041 ocpp_core::decode_payload::<GetInstalledCertificateIdsResponse>(payload)
2042 .map(|r| serde_json::to_value(r).expect("serializable"))
2043 }
2044 Action::GetLocalListVersion => {
2045 ocpp_core::decode_payload::<GetLocalListVersionResponse>(payload)
2046 .map(|r| serde_json::to_value(r).expect("serializable"))
2047 }
2048 Action::GetLog => ocpp_core::decode_payload::<GetLogResponse>(payload)
2049 .map(|r| serde_json::to_value(r).expect("serializable")),
2050 Action::GetMonitoringReport => {
2051 ocpp_core::decode_payload::<GetMonitoringReportResponse>(payload)
2052 .map(|r| serde_json::to_value(r).expect("serializable"))
2053 }
2054 Action::GetPeriodicEventStream => {
2055 ocpp_core::decode_payload::<GetPeriodicEventStreamResponse>(payload)
2056 .map(|r| serde_json::to_value(r).expect("serializable"))
2057 }
2058 Action::GetReport => ocpp_core::decode_payload::<GetReportResponse>(payload)
2059 .map(|r| serde_json::to_value(r).expect("serializable")),
2060 Action::GetTariffs => ocpp_core::decode_payload::<GetTariffsResponse>(payload)
2061 .map(|r| serde_json::to_value(r).expect("serializable")),
2062 Action::GetTransactionStatus => {
2063 ocpp_core::decode_payload::<GetTransactionStatusResponse>(payload)
2064 .map(|r| serde_json::to_value(r).expect("serializable"))
2065 }
2066 Action::GetVariables => ocpp_core::decode_payload::<GetVariablesResponse>(payload)
2067 .map(|r| serde_json::to_value(r).expect("serializable")),
2068 Action::Heartbeat => ocpp_core::decode_payload::<HeartbeatResponse>(payload)
2069 .map(|r| serde_json::to_value(r).expect("serializable")),
2070 Action::InstallCertificate => {
2071 ocpp_core::decode_payload::<InstallCertificateResponse>(payload)
2072 .map(|r| serde_json::to_value(r).expect("serializable"))
2073 }
2074 Action::LogStatusNotification => {
2075 ocpp_core::decode_payload::<LogStatusNotificationResponse>(payload)
2076 .map(|r| serde_json::to_value(r).expect("serializable"))
2077 }
2078 Action::MeterValues => ocpp_core::decode_payload::<MeterValuesResponse>(payload)
2079 .map(|r| serde_json::to_value(r).expect("serializable")),
2080 Action::NotifyAllowedEnergyTransfer => {
2081 ocpp_core::decode_payload::<NotifyAllowedEnergyTransferResponse>(payload)
2082 .map(|r| serde_json::to_value(r).expect("serializable"))
2083 }
2084 Action::NotifyChargingLimit => {
2085 ocpp_core::decode_payload::<NotifyChargingLimitResponse>(payload)
2086 .map(|r| serde_json::to_value(r).expect("serializable"))
2087 }
2088 Action::NotifyCustomerInformation => {
2089 ocpp_core::decode_payload::<NotifyCustomerInformationResponse>(payload)
2090 .map(|r| serde_json::to_value(r).expect("serializable"))
2091 }
2092 Action::NotifyDERAlarm => ocpp_core::decode_payload::<NotifyDERAlarmResponse>(payload)
2093 .map(|r| serde_json::to_value(r).expect("serializable")),
2094 Action::NotifyDERStartStop => {
2095 ocpp_core::decode_payload::<NotifyDERStartStopResponse>(payload)
2096 .map(|r| serde_json::to_value(r).expect("serializable"))
2097 }
2098 Action::NotifyDisplayMessages => {
2099 ocpp_core::decode_payload::<NotifyDisplayMessagesResponse>(payload)
2100 .map(|r| serde_json::to_value(r).expect("serializable"))
2101 }
2102 Action::NotifyEVChargingNeeds => {
2103 ocpp_core::decode_payload::<NotifyEVChargingNeedsResponse>(payload)
2104 .map(|r| serde_json::to_value(r).expect("serializable"))
2105 }
2106 Action::NotifyEVChargingSchedule => {
2107 ocpp_core::decode_payload::<NotifyEVChargingScheduleResponse>(payload)
2108 .map(|r| serde_json::to_value(r).expect("serializable"))
2109 }
2110 Action::NotifyEvent => ocpp_core::decode_payload::<NotifyEventResponse>(payload)
2111 .map(|r| serde_json::to_value(r).expect("serializable")),
2112 Action::NotifyMonitoringReport => {
2113 ocpp_core::decode_payload::<NotifyMonitoringReportResponse>(payload)
2114 .map(|r| serde_json::to_value(r).expect("serializable"))
2115 }
2116 Action::NotifyPriorityCharging => {
2117 ocpp_core::decode_payload::<NotifyPriorityChargingResponse>(payload)
2118 .map(|r| serde_json::to_value(r).expect("serializable"))
2119 }
2120 Action::NotifyReport => ocpp_core::decode_payload::<NotifyReportResponse>(payload)
2121 .map(|r| serde_json::to_value(r).expect("serializable")),
2122 Action::NotifySettlement => ocpp_core::decode_payload::<NotifySettlementResponse>(payload)
2123 .map(|r| serde_json::to_value(r).expect("serializable")),
2124 Action::NotifyWebPaymentStarted => {
2125 ocpp_core::decode_payload::<NotifyWebPaymentStartedResponse>(payload)
2126 .map(|r| serde_json::to_value(r).expect("serializable"))
2127 }
2128 Action::OpenPeriodicEventStream => {
2129 ocpp_core::decode_payload::<OpenPeriodicEventStreamResponse>(payload)
2130 .map(|r| serde_json::to_value(r).expect("serializable"))
2131 }
2132 Action::PublishFirmware => ocpp_core::decode_payload::<PublishFirmwareResponse>(payload)
2133 .map(|r| serde_json::to_value(r).expect("serializable")),
2134 Action::PublishFirmwareStatusNotification => {
2135 ocpp_core::decode_payload::<PublishFirmwareStatusNotificationResponse>(payload)
2136 .map(|r| serde_json::to_value(r).expect("serializable"))
2137 }
2138 Action::PullDynamicScheduleUpdate => {
2139 ocpp_core::decode_payload::<PullDynamicScheduleUpdateResponse>(payload)
2140 .map(|r| serde_json::to_value(r).expect("serializable"))
2141 }
2142 Action::ReportChargingProfiles => {
2143 ocpp_core::decode_payload::<ReportChargingProfilesResponse>(payload)
2144 .map(|r| serde_json::to_value(r).expect("serializable"))
2145 }
2146 Action::ReportDERControl => ocpp_core::decode_payload::<ReportDERControlResponse>(payload)
2147 .map(|r| serde_json::to_value(r).expect("serializable")),
2148 Action::RequestBatterySwap => {
2149 ocpp_core::decode_payload::<RequestBatterySwapResponse>(payload)
2150 .map(|r| serde_json::to_value(r).expect("serializable"))
2151 }
2152 Action::RequestStartTransaction => {
2153 ocpp_core::decode_payload::<RequestStartTransactionResponse>(payload)
2154 .map(|r| serde_json::to_value(r).expect("serializable"))
2155 }
2156 Action::RequestStopTransaction => {
2157 ocpp_core::decode_payload::<RequestStopTransactionResponse>(payload)
2158 .map(|r| serde_json::to_value(r).expect("serializable"))
2159 }
2160 Action::ReservationStatusUpdate => {
2161 ocpp_core::decode_payload::<ReservationStatusUpdateResponse>(payload)
2162 .map(|r| serde_json::to_value(r).expect("serializable"))
2163 }
2164 Action::ReserveNow => ocpp_core::decode_payload::<ReserveNowResponse>(payload)
2165 .map(|r| serde_json::to_value(r).expect("serializable")),
2166 Action::Reset => ocpp_core::decode_payload::<ResetResponse>(payload)
2167 .map(|r| serde_json::to_value(r).expect("serializable")),
2168 Action::SecurityEventNotification => {
2169 ocpp_core::decode_payload::<SecurityEventNotificationResponse>(payload)
2170 .map(|r| serde_json::to_value(r).expect("serializable"))
2171 }
2172 Action::SendLocalList => ocpp_core::decode_payload::<SendLocalListResponse>(payload)
2173 .map(|r| serde_json::to_value(r).expect("serializable")),
2174 Action::SetChargingProfile => {
2175 ocpp_core::decode_payload::<SetChargingProfileResponse>(payload)
2176 .map(|r| serde_json::to_value(r).expect("serializable"))
2177 }
2178 Action::SetDERControl => ocpp_core::decode_payload::<SetDERControlResponse>(payload)
2179 .map(|r| serde_json::to_value(r).expect("serializable")),
2180 Action::SetDefaultTariff => ocpp_core::decode_payload::<SetDefaultTariffResponse>(payload)
2181 .map(|r| serde_json::to_value(r).expect("serializable")),
2182 Action::SetDisplayMessage => {
2183 ocpp_core::decode_payload::<SetDisplayMessageResponse>(payload)
2184 .map(|r| serde_json::to_value(r).expect("serializable"))
2185 }
2186 Action::SetMonitoringBase => {
2187 ocpp_core::decode_payload::<SetMonitoringBaseResponse>(payload)
2188 .map(|r| serde_json::to_value(r).expect("serializable"))
2189 }
2190 Action::SetMonitoringLevel => {
2191 ocpp_core::decode_payload::<SetMonitoringLevelResponse>(payload)
2192 .map(|r| serde_json::to_value(r).expect("serializable"))
2193 }
2194 Action::SetNetworkProfile => {
2195 ocpp_core::decode_payload::<SetNetworkProfileResponse>(payload)
2196 .map(|r| serde_json::to_value(r).expect("serializable"))
2197 }
2198 Action::SetVariableMonitoring => {
2199 ocpp_core::decode_payload::<SetVariableMonitoringResponse>(payload)
2200 .map(|r| serde_json::to_value(r).expect("serializable"))
2201 }
2202 Action::SetVariables => ocpp_core::decode_payload::<SetVariablesResponse>(payload)
2203 .map(|r| serde_json::to_value(r).expect("serializable")),
2204 Action::SignCertificate => ocpp_core::decode_payload::<SignCertificateResponse>(payload)
2205 .map(|r| serde_json::to_value(r).expect("serializable")),
2206 Action::StatusNotification => {
2207 ocpp_core::decode_payload::<StatusNotificationResponse>(payload)
2208 .map(|r| serde_json::to_value(r).expect("serializable"))
2209 }
2210 Action::TransactionEvent => ocpp_core::decode_payload::<TransactionEventResponse>(payload)
2211 .map(|r| serde_json::to_value(r).expect("serializable")),
2212 Action::TriggerMessage => ocpp_core::decode_payload::<TriggerMessageResponse>(payload)
2213 .map(|r| serde_json::to_value(r).expect("serializable")),
2214 Action::UnlockConnector => ocpp_core::decode_payload::<UnlockConnectorResponse>(payload)
2215 .map(|r| serde_json::to_value(r).expect("serializable")),
2216 Action::UnpublishFirmware => {
2217 ocpp_core::decode_payload::<UnpublishFirmwareResponse>(payload)
2218 .map(|r| serde_json::to_value(r).expect("serializable"))
2219 }
2220 Action::UpdateDynamicSchedule => {
2221 ocpp_core::decode_payload::<UpdateDynamicScheduleResponse>(payload)
2222 .map(|r| serde_json::to_value(r).expect("serializable"))
2223 }
2224 Action::UpdateFirmware => ocpp_core::decode_payload::<UpdateFirmwareResponse>(payload)
2225 .map(|r| serde_json::to_value(r).expect("serializable")),
2226 Action::UsePriorityCharging => {
2227 ocpp_core::decode_payload::<UsePriorityChargingResponse>(payload)
2228 .map(|r| serde_json::to_value(r).expect("serializable"))
2229 }
2230 Action::VatNumberValidation => {
2231 ocpp_core::decode_payload::<VatNumberValidationResponse>(payload)
2232 .map(|r| serde_json::to_value(r).expect("serializable"))
2233 }
2234 _ => Err(Violation::new(
2235 ocpp_core::ViolationKind::Format,
2236 "SEND messages have no response",
2237 )),
2238 }
2239}