1#![allow(unused_imports, clippy::doc_markdown, clippy::struct_excessive_bools)]
7#![allow(
8 clippy::too_many_lines,
9 clippy::too_many_arguments,
10 clippy::wildcard_imports
11)]
12#![allow(clippy::match_same_arms, clippy::fn_params_excessive_bools)]
13
14use alloc::string::String;
15use alloc::vec::Vec;
16
17use serde::{Deserialize, Serialize};
18
19use super::messages::*;
20use crate::decode::{DecodeError, DecodeOptions};
21use crate::message::{MessageKind, Origin};
22use crate::validate::{Validate, ValidationPath, Violations};
23use serde_json::value::RawValue;
24
25#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
29#[non_exhaustive]
30pub enum Action {
31 Authorize,
33 BootNotification,
35 CancelReservation,
37 CertificateSigned,
39 ChangeAvailability,
41 ClearCache,
43 ClearChargingProfile,
45 ClearDisplayMessage,
47 ClearVariableMonitoring,
49 ClearedChargingLimit,
51 CostUpdated,
53 CustomerInformation,
55 DataTransfer,
57 DeleteCertificate,
59 FirmwareStatusNotification,
61 Get15118EVCertificate,
63 GetBaseReport,
65 GetCertificateStatus,
67 GetChargingProfiles,
69 GetCompositeSchedule,
71 GetDisplayMessages,
73 GetInstalledCertificateIds,
75 GetLocalListVersion,
77 GetLog,
79 GetMonitoringReport,
81 GetReport,
83 GetTransactionStatus,
85 GetVariables,
87 Heartbeat,
89 InstallCertificate,
91 LogStatusNotification,
93 MeterValues,
95 NotifyChargingLimit,
97 NotifyCustomerInformation,
99 NotifyDisplayMessages,
101 NotifyEVChargingNeeds,
103 NotifyEVChargingSchedule,
105 NotifyEvent,
107 NotifyMonitoringReport,
109 NotifyReport,
111 PublishFirmware,
113 PublishFirmwareStatusNotification,
115 ReportChargingProfiles,
117 RequestStartTransaction,
119 RequestStopTransaction,
121 ReservationStatusUpdate,
123 ReserveNow,
125 Reset,
127 SecurityEventNotification,
129 SendLocalList,
131 SetChargingProfile,
133 SetDisplayMessage,
135 SetMonitoringBase,
137 SetMonitoringLevel,
139 SetNetworkProfile,
141 SetVariableMonitoring,
143 SetVariables,
145 SignCertificate,
147 StatusNotification,
149 TransactionEvent,
151 TriggerMessage,
153 UnlockConnector,
155 UnpublishFirmware,
157 UpdateFirmware,
159}
160
161impl Action {
162 pub const ALL: &'static [Action] = &[
164 Action::Authorize,
165 Action::BootNotification,
166 Action::CancelReservation,
167 Action::CertificateSigned,
168 Action::ChangeAvailability,
169 Action::ClearCache,
170 Action::ClearChargingProfile,
171 Action::ClearDisplayMessage,
172 Action::ClearVariableMonitoring,
173 Action::ClearedChargingLimit,
174 Action::CostUpdated,
175 Action::CustomerInformation,
176 Action::DataTransfer,
177 Action::DeleteCertificate,
178 Action::FirmwareStatusNotification,
179 Action::Get15118EVCertificate,
180 Action::GetBaseReport,
181 Action::GetCertificateStatus,
182 Action::GetChargingProfiles,
183 Action::GetCompositeSchedule,
184 Action::GetDisplayMessages,
185 Action::GetInstalledCertificateIds,
186 Action::GetLocalListVersion,
187 Action::GetLog,
188 Action::GetMonitoringReport,
189 Action::GetReport,
190 Action::GetTransactionStatus,
191 Action::GetVariables,
192 Action::Heartbeat,
193 Action::InstallCertificate,
194 Action::LogStatusNotification,
195 Action::MeterValues,
196 Action::NotifyChargingLimit,
197 Action::NotifyCustomerInformation,
198 Action::NotifyDisplayMessages,
199 Action::NotifyEVChargingNeeds,
200 Action::NotifyEVChargingSchedule,
201 Action::NotifyEvent,
202 Action::NotifyMonitoringReport,
203 Action::NotifyReport,
204 Action::PublishFirmware,
205 Action::PublishFirmwareStatusNotification,
206 Action::ReportChargingProfiles,
207 Action::RequestStartTransaction,
208 Action::RequestStopTransaction,
209 Action::ReservationStatusUpdate,
210 Action::ReserveNow,
211 Action::Reset,
212 Action::SecurityEventNotification,
213 Action::SendLocalList,
214 Action::SetChargingProfile,
215 Action::SetDisplayMessage,
216 Action::SetMonitoringBase,
217 Action::SetMonitoringLevel,
218 Action::SetNetworkProfile,
219 Action::SetVariableMonitoring,
220 Action::SetVariables,
221 Action::SignCertificate,
222 Action::StatusNotification,
223 Action::TransactionEvent,
224 Action::TriggerMessage,
225 Action::UnlockConnector,
226 Action::UnpublishFirmware,
227 Action::UpdateFirmware,
228 ];
229
230 #[must_use]
232 pub const fn as_str(self) -> &'static str {
233 match self {
234 Action::Authorize => "Authorize",
235 Action::BootNotification => "BootNotification",
236 Action::CancelReservation => "CancelReservation",
237 Action::CertificateSigned => "CertificateSigned",
238 Action::ChangeAvailability => "ChangeAvailability",
239 Action::ClearCache => "ClearCache",
240 Action::ClearChargingProfile => "ClearChargingProfile",
241 Action::ClearDisplayMessage => "ClearDisplayMessage",
242 Action::ClearVariableMonitoring => "ClearVariableMonitoring",
243 Action::ClearedChargingLimit => "ClearedChargingLimit",
244 Action::CostUpdated => "CostUpdated",
245 Action::CustomerInformation => "CustomerInformation",
246 Action::DataTransfer => "DataTransfer",
247 Action::DeleteCertificate => "DeleteCertificate",
248 Action::FirmwareStatusNotification => "FirmwareStatusNotification",
249 Action::Get15118EVCertificate => "Get15118EVCertificate",
250 Action::GetBaseReport => "GetBaseReport",
251 Action::GetCertificateStatus => "GetCertificateStatus",
252 Action::GetChargingProfiles => "GetChargingProfiles",
253 Action::GetCompositeSchedule => "GetCompositeSchedule",
254 Action::GetDisplayMessages => "GetDisplayMessages",
255 Action::GetInstalledCertificateIds => "GetInstalledCertificateIds",
256 Action::GetLocalListVersion => "GetLocalListVersion",
257 Action::GetLog => "GetLog",
258 Action::GetMonitoringReport => "GetMonitoringReport",
259 Action::GetReport => "GetReport",
260 Action::GetTransactionStatus => "GetTransactionStatus",
261 Action::GetVariables => "GetVariables",
262 Action::Heartbeat => "Heartbeat",
263 Action::InstallCertificate => "InstallCertificate",
264 Action::LogStatusNotification => "LogStatusNotification",
265 Action::MeterValues => "MeterValues",
266 Action::NotifyChargingLimit => "NotifyChargingLimit",
267 Action::NotifyCustomerInformation => "NotifyCustomerInformation",
268 Action::NotifyDisplayMessages => "NotifyDisplayMessages",
269 Action::NotifyEVChargingNeeds => "NotifyEVChargingNeeds",
270 Action::NotifyEVChargingSchedule => "NotifyEVChargingSchedule",
271 Action::NotifyEvent => "NotifyEvent",
272 Action::NotifyMonitoringReport => "NotifyMonitoringReport",
273 Action::NotifyReport => "NotifyReport",
274 Action::PublishFirmware => "PublishFirmware",
275 Action::PublishFirmwareStatusNotification => "PublishFirmwareStatusNotification",
276 Action::ReportChargingProfiles => "ReportChargingProfiles",
277 Action::RequestStartTransaction => "RequestStartTransaction",
278 Action::RequestStopTransaction => "RequestStopTransaction",
279 Action::ReservationStatusUpdate => "ReservationStatusUpdate",
280 Action::ReserveNow => "ReserveNow",
281 Action::Reset => "Reset",
282 Action::SecurityEventNotification => "SecurityEventNotification",
283 Action::SendLocalList => "SendLocalList",
284 Action::SetChargingProfile => "SetChargingProfile",
285 Action::SetDisplayMessage => "SetDisplayMessage",
286 Action::SetMonitoringBase => "SetMonitoringBase",
287 Action::SetMonitoringLevel => "SetMonitoringLevel",
288 Action::SetNetworkProfile => "SetNetworkProfile",
289 Action::SetVariableMonitoring => "SetVariableMonitoring",
290 Action::SetVariables => "SetVariables",
291 Action::SignCertificate => "SignCertificate",
292 Action::StatusNotification => "StatusNotification",
293 Action::TransactionEvent => "TransactionEvent",
294 Action::TriggerMessage => "TriggerMessage",
295 Action::UnlockConnector => "UnlockConnector",
296 Action::UnpublishFirmware => "UnpublishFirmware",
297 Action::UpdateFirmware => "UpdateFirmware",
298 }
299 }
300
301 #[must_use]
303 pub fn from_wire(name: &str) -> Option<Self> {
304 Some(match name {
305 "Authorize" => Action::Authorize,
306 "BootNotification" => Action::BootNotification,
307 "CancelReservation" => Action::CancelReservation,
308 "CertificateSigned" => Action::CertificateSigned,
309 "ChangeAvailability" => Action::ChangeAvailability,
310 "ClearCache" => Action::ClearCache,
311 "ClearChargingProfile" => Action::ClearChargingProfile,
312 "ClearDisplayMessage" => Action::ClearDisplayMessage,
313 "ClearVariableMonitoring" => Action::ClearVariableMonitoring,
314 "ClearedChargingLimit" => Action::ClearedChargingLimit,
315 "CostUpdated" => Action::CostUpdated,
316 "CustomerInformation" => Action::CustomerInformation,
317 "DataTransfer" => Action::DataTransfer,
318 "DeleteCertificate" => Action::DeleteCertificate,
319 "FirmwareStatusNotification" => Action::FirmwareStatusNotification,
320 "Get15118EVCertificate" => Action::Get15118EVCertificate,
321 "GetBaseReport" => Action::GetBaseReport,
322 "GetCertificateStatus" => Action::GetCertificateStatus,
323 "GetChargingProfiles" => Action::GetChargingProfiles,
324 "GetCompositeSchedule" => Action::GetCompositeSchedule,
325 "GetDisplayMessages" => Action::GetDisplayMessages,
326 "GetInstalledCertificateIds" => Action::GetInstalledCertificateIds,
327 "GetLocalListVersion" => Action::GetLocalListVersion,
328 "GetLog" => Action::GetLog,
329 "GetMonitoringReport" => Action::GetMonitoringReport,
330 "GetReport" => Action::GetReport,
331 "GetTransactionStatus" => Action::GetTransactionStatus,
332 "GetVariables" => Action::GetVariables,
333 "Heartbeat" => Action::Heartbeat,
334 "InstallCertificate" => Action::InstallCertificate,
335 "LogStatusNotification" => Action::LogStatusNotification,
336 "MeterValues" => Action::MeterValues,
337 "NotifyChargingLimit" => Action::NotifyChargingLimit,
338 "NotifyCustomerInformation" => Action::NotifyCustomerInformation,
339 "NotifyDisplayMessages" => Action::NotifyDisplayMessages,
340 "NotifyEVChargingNeeds" => Action::NotifyEVChargingNeeds,
341 "NotifyEVChargingSchedule" => Action::NotifyEVChargingSchedule,
342 "NotifyEvent" => Action::NotifyEvent,
343 "NotifyMonitoringReport" => Action::NotifyMonitoringReport,
344 "NotifyReport" => Action::NotifyReport,
345 "PublishFirmware" => Action::PublishFirmware,
346 "PublishFirmwareStatusNotification" => Action::PublishFirmwareStatusNotification,
347 "ReportChargingProfiles" => Action::ReportChargingProfiles,
348 "RequestStartTransaction" => Action::RequestStartTransaction,
349 "RequestStopTransaction" => Action::RequestStopTransaction,
350 "ReservationStatusUpdate" => Action::ReservationStatusUpdate,
351 "ReserveNow" => Action::ReserveNow,
352 "Reset" => Action::Reset,
353 "SecurityEventNotification" => Action::SecurityEventNotification,
354 "SendLocalList" => Action::SendLocalList,
355 "SetChargingProfile" => Action::SetChargingProfile,
356 "SetDisplayMessage" => Action::SetDisplayMessage,
357 "SetMonitoringBase" => Action::SetMonitoringBase,
358 "SetMonitoringLevel" => Action::SetMonitoringLevel,
359 "SetNetworkProfile" => Action::SetNetworkProfile,
360 "SetVariableMonitoring" => Action::SetVariableMonitoring,
361 "SetVariables" => Action::SetVariables,
362 "SignCertificate" => Action::SignCertificate,
363 "StatusNotification" => Action::StatusNotification,
364 "TransactionEvent" => Action::TransactionEvent,
365 "TriggerMessage" => Action::TriggerMessage,
366 "UnlockConnector" => Action::UnlockConnector,
367 "UnpublishFirmware" => Action::UnpublishFirmware,
368 "UpdateFirmware" => Action::UpdateFirmware,
369 _ => return None,
370 })
371 }
372
373 #[must_use]
375 pub const fn kind(self) -> MessageKind {
376 MessageKind::Call
377 }
378
379 #[must_use]
381 pub const fn origin(self) -> Origin {
382 match self {
383 Action::Authorize => Origin::ChargingStation,
384 Action::BootNotification => Origin::ChargingStation,
385 Action::CancelReservation => Origin::Csms,
386 Action::CertificateSigned => Origin::Csms,
387 Action::ChangeAvailability => Origin::Csms,
388 Action::ClearCache => Origin::Csms,
389 Action::ClearChargingProfile => Origin::Csms,
390 Action::ClearDisplayMessage => Origin::Csms,
391 Action::ClearVariableMonitoring => Origin::Csms,
392 Action::ClearedChargingLimit => Origin::ChargingStation,
393 Action::CostUpdated => Origin::Csms,
394 Action::CustomerInformation => Origin::Csms,
395 Action::DataTransfer => Origin::Both,
396 Action::DeleteCertificate => Origin::Csms,
397 Action::FirmwareStatusNotification => Origin::ChargingStation,
398 Action::Get15118EVCertificate => Origin::ChargingStation,
399 Action::GetBaseReport => Origin::Csms,
400 Action::GetCertificateStatus => Origin::ChargingStation,
401 Action::GetChargingProfiles => Origin::Csms,
402 Action::GetCompositeSchedule => Origin::Csms,
403 Action::GetDisplayMessages => Origin::Csms,
404 Action::GetInstalledCertificateIds => Origin::Csms,
405 Action::GetLocalListVersion => Origin::Csms,
406 Action::GetLog => Origin::Csms,
407 Action::GetMonitoringReport => Origin::Csms,
408 Action::GetReport => Origin::Csms,
409 Action::GetTransactionStatus => Origin::Csms,
410 Action::GetVariables => Origin::Csms,
411 Action::Heartbeat => Origin::ChargingStation,
412 Action::InstallCertificate => Origin::Csms,
413 Action::LogStatusNotification => Origin::ChargingStation,
414 Action::MeterValues => Origin::ChargingStation,
415 Action::NotifyChargingLimit => Origin::ChargingStation,
416 Action::NotifyCustomerInformation => Origin::ChargingStation,
417 Action::NotifyDisplayMessages => Origin::ChargingStation,
418 Action::NotifyEVChargingNeeds => Origin::ChargingStation,
419 Action::NotifyEVChargingSchedule => Origin::ChargingStation,
420 Action::NotifyEvent => Origin::ChargingStation,
421 Action::NotifyMonitoringReport => Origin::ChargingStation,
422 Action::NotifyReport => Origin::ChargingStation,
423 Action::PublishFirmware => Origin::Csms,
424 Action::PublishFirmwareStatusNotification => Origin::ChargingStation,
425 Action::ReportChargingProfiles => Origin::ChargingStation,
426 Action::RequestStartTransaction => Origin::Csms,
427 Action::RequestStopTransaction => Origin::Csms,
428 Action::ReservationStatusUpdate => Origin::ChargingStation,
429 Action::ReserveNow => Origin::Csms,
430 Action::Reset => Origin::Csms,
431 Action::SecurityEventNotification => Origin::ChargingStation,
432 Action::SendLocalList => Origin::Csms,
433 Action::SetChargingProfile => Origin::Csms,
434 Action::SetDisplayMessage => Origin::Csms,
435 Action::SetMonitoringBase => Origin::Csms,
436 Action::SetMonitoringLevel => Origin::Csms,
437 Action::SetNetworkProfile => Origin::Csms,
438 Action::SetVariableMonitoring => Origin::Csms,
439 Action::SetVariables => Origin::Csms,
440 Action::SignCertificate => Origin::ChargingStation,
441 Action::StatusNotification => Origin::ChargingStation,
442 Action::TransactionEvent => Origin::ChargingStation,
443 Action::TriggerMessage => Origin::Csms,
444 Action::UnlockConnector => Origin::Csms,
445 Action::UnpublishFirmware => Origin::Csms,
446 Action::UpdateFirmware => Origin::Csms,
447 }
448 }
449
450 #[must_use]
452 pub const fn block(self) -> &'static str {
453 match self {
454 Action::Authorize => "C",
455 Action::BootNotification => "B",
456 Action::CancelReservation => "H",
457 Action::CertificateSigned => "A",
458 Action::ChangeAvailability => "G",
459 Action::ClearCache => "C",
460 Action::ClearChargingProfile => "K",
461 Action::ClearDisplayMessage => "O",
462 Action::ClearVariableMonitoring => "N",
463 Action::ClearedChargingLimit => "K",
464 Action::CostUpdated => "I",
465 Action::CustomerInformation => "N",
466 Action::DataTransfer => "P",
467 Action::DeleteCertificate => "M",
468 Action::FirmwareStatusNotification => "L",
469 Action::Get15118EVCertificate => "M",
470 Action::GetBaseReport => "B",
471 Action::GetCertificateStatus => "M",
472 Action::GetChargingProfiles => "K",
473 Action::GetCompositeSchedule => "K",
474 Action::GetDisplayMessages => "O",
475 Action::GetInstalledCertificateIds => "M",
476 Action::GetLocalListVersion => "D",
477 Action::GetLog => "N",
478 Action::GetMonitoringReport => "N",
479 Action::GetReport => "B",
480 Action::GetTransactionStatus => "E",
481 Action::GetVariables => "B",
482 Action::Heartbeat => "B",
483 Action::InstallCertificate => "M",
484 Action::LogStatusNotification => "N",
485 Action::MeterValues => "J",
486 Action::NotifyChargingLimit => "K",
487 Action::NotifyCustomerInformation => "N",
488 Action::NotifyDisplayMessages => "O",
489 Action::NotifyEVChargingNeeds => "K",
490 Action::NotifyEVChargingSchedule => "K",
491 Action::NotifyEvent => "N",
492 Action::NotifyMonitoringReport => "N",
493 Action::NotifyReport => "B",
494 Action::PublishFirmware => "L",
495 Action::PublishFirmwareStatusNotification => "L",
496 Action::ReportChargingProfiles => "K",
497 Action::RequestStartTransaction => "F",
498 Action::RequestStopTransaction => "F",
499 Action::ReservationStatusUpdate => "H",
500 Action::ReserveNow => "H",
501 Action::Reset => "B",
502 Action::SecurityEventNotification => "A",
503 Action::SendLocalList => "D",
504 Action::SetChargingProfile => "K",
505 Action::SetDisplayMessage => "O",
506 Action::SetMonitoringBase => "N",
507 Action::SetMonitoringLevel => "N",
508 Action::SetNetworkProfile => "B",
509 Action::SetVariableMonitoring => "N",
510 Action::SetVariables => "B",
511 Action::SignCertificate => "A",
512 Action::StatusNotification => "G",
513 Action::TransactionEvent => "E",
514 Action::TriggerMessage => "F",
515 Action::UnlockConnector => "F",
516 Action::UnpublishFirmware => "L",
517 Action::UpdateFirmware => "L",
518 }
519 }
520}
521
522impl crate::message::ActionName for Action {
523 fn all() -> &'static [Self] {
524 Self::ALL
525 }
526 fn as_str(&self) -> &'static str {
527 Action::as_str(*self)
528 }
529 fn from_wire(name: &str) -> Option<Self> {
530 Action::from_wire(name)
531 }
532 fn kind(&self) -> MessageKind {
533 Action::kind(*self)
534 }
535 fn origin(&self) -> Origin {
536 Action::origin(*self)
537 }
538 fn block(&self) -> &'static str {
539 Action::block(*self)
540 }
541}
542
543impl core::fmt::Display for Action {
544 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
545 f.write_str(self.as_str())
546 }
547}
548
549impl core::str::FromStr for Action {
550 type Err = crate::message::UnknownAction;
551 fn from_str(s: &str) -> Result<Self, Self::Err> {
552 Self::from_wire(s).ok_or(crate::message::UnknownAction)
553 }
554}
555
556impl Serialize for Action {
557 fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
558 ser.serialize_str(self.as_str())
559 }
560}
561
562impl<'de> Deserialize<'de> for Action {
563 fn deserialize<D: serde::Deserializer<'de>>(de: D) -> Result<Self, D::Error> {
564 let s = <&str as Deserialize>::deserialize(de)?;
565 Self::from_wire(s).ok_or_else(|| serde::de::Error::custom("unknown OCPP action"))
566 }
567}
568
569impl Action {
570 #[must_use]
574 pub const fn has_response(self) -> bool {
575 matches!(self.kind(), MessageKind::Call)
576 }
577}
578
579pub fn transcode_request(
585 action: Action,
586 payload: &RawValue,
587 options: &DecodeOptions,
588) -> Result<alloc::boxed::Box<RawValue>, DecodeError> {
589 match action {
590 Action::Authorize => crate::decode::transcode::<AuthorizeRequest>(payload, options),
591 Action::BootNotification => {
592 crate::decode::transcode::<BootNotificationRequest>(payload, options)
593 }
594 Action::CancelReservation => {
595 crate::decode::transcode::<CancelReservationRequest>(payload, options)
596 }
597 Action::CertificateSigned => {
598 crate::decode::transcode::<CertificateSignedRequest>(payload, options)
599 }
600 Action::ChangeAvailability => {
601 crate::decode::transcode::<ChangeAvailabilityRequest>(payload, options)
602 }
603 Action::ClearCache => crate::decode::transcode::<ClearCacheRequest>(payload, options),
604 Action::ClearChargingProfile => {
605 crate::decode::transcode::<ClearChargingProfileRequest>(payload, options)
606 }
607 Action::ClearDisplayMessage => {
608 crate::decode::transcode::<ClearDisplayMessageRequest>(payload, options)
609 }
610 Action::ClearVariableMonitoring => {
611 crate::decode::transcode::<ClearVariableMonitoringRequest>(payload, options)
612 }
613 Action::ClearedChargingLimit => {
614 crate::decode::transcode::<ClearedChargingLimitRequest>(payload, options)
615 }
616 Action::CostUpdated => crate::decode::transcode::<CostUpdatedRequest>(payload, options),
617 Action::CustomerInformation => {
618 crate::decode::transcode::<CustomerInformationRequest>(payload, options)
619 }
620 Action::DataTransfer => crate::decode::transcode::<DataTransferRequest>(payload, options),
621 Action::DeleteCertificate => {
622 crate::decode::transcode::<DeleteCertificateRequest>(payload, options)
623 }
624 Action::FirmwareStatusNotification => {
625 crate::decode::transcode::<FirmwareStatusNotificationRequest>(payload, options)
626 }
627 Action::Get15118EVCertificate => {
628 crate::decode::transcode::<Get15118EVCertificateRequest>(payload, options)
629 }
630 Action::GetBaseReport => crate::decode::transcode::<GetBaseReportRequest>(payload, options),
631 Action::GetCertificateStatus => {
632 crate::decode::transcode::<GetCertificateStatusRequest>(payload, options)
633 }
634 Action::GetChargingProfiles => {
635 crate::decode::transcode::<GetChargingProfilesRequest>(payload, options)
636 }
637 Action::GetCompositeSchedule => {
638 crate::decode::transcode::<GetCompositeScheduleRequest>(payload, options)
639 }
640 Action::GetDisplayMessages => {
641 crate::decode::transcode::<GetDisplayMessagesRequest>(payload, options)
642 }
643 Action::GetInstalledCertificateIds => {
644 crate::decode::transcode::<GetInstalledCertificateIdsRequest>(payload, options)
645 }
646 Action::GetLocalListVersion => {
647 crate::decode::transcode::<GetLocalListVersionRequest>(payload, options)
648 }
649 Action::GetLog => crate::decode::transcode::<GetLogRequest>(payload, options),
650 Action::GetMonitoringReport => {
651 crate::decode::transcode::<GetMonitoringReportRequest>(payload, options)
652 }
653 Action::GetReport => crate::decode::transcode::<GetReportRequest>(payload, options),
654 Action::GetTransactionStatus => {
655 crate::decode::transcode::<GetTransactionStatusRequest>(payload, options)
656 }
657 Action::GetVariables => crate::decode::transcode::<GetVariablesRequest>(payload, options),
658 Action::Heartbeat => crate::decode::transcode::<HeartbeatRequest>(payload, options),
659 Action::InstallCertificate => {
660 crate::decode::transcode::<InstallCertificateRequest>(payload, options)
661 }
662 Action::LogStatusNotification => {
663 crate::decode::transcode::<LogStatusNotificationRequest>(payload, options)
664 }
665 Action::MeterValues => crate::decode::transcode::<MeterValuesRequest>(payload, options),
666 Action::NotifyChargingLimit => {
667 crate::decode::transcode::<NotifyChargingLimitRequest>(payload, options)
668 }
669 Action::NotifyCustomerInformation => {
670 crate::decode::transcode::<NotifyCustomerInformationRequest>(payload, options)
671 }
672 Action::NotifyDisplayMessages => {
673 crate::decode::transcode::<NotifyDisplayMessagesRequest>(payload, options)
674 }
675 Action::NotifyEVChargingNeeds => {
676 crate::decode::transcode::<NotifyEVChargingNeedsRequest>(payload, options)
677 }
678 Action::NotifyEVChargingSchedule => {
679 crate::decode::transcode::<NotifyEVChargingScheduleRequest>(payload, options)
680 }
681 Action::NotifyEvent => crate::decode::transcode::<NotifyEventRequest>(payload, options),
682 Action::NotifyMonitoringReport => {
683 crate::decode::transcode::<NotifyMonitoringReportRequest>(payload, options)
684 }
685 Action::NotifyReport => crate::decode::transcode::<NotifyReportRequest>(payload, options),
686 Action::PublishFirmware => {
687 crate::decode::transcode::<PublishFirmwareRequest>(payload, options)
688 }
689 Action::PublishFirmwareStatusNotification => {
690 crate::decode::transcode::<PublishFirmwareStatusNotificationRequest>(payload, options)
691 }
692 Action::ReportChargingProfiles => {
693 crate::decode::transcode::<ReportChargingProfilesRequest>(payload, options)
694 }
695 Action::RequestStartTransaction => {
696 crate::decode::transcode::<RequestStartTransactionRequest>(payload, options)
697 }
698 Action::RequestStopTransaction => {
699 crate::decode::transcode::<RequestStopTransactionRequest>(payload, options)
700 }
701 Action::ReservationStatusUpdate => {
702 crate::decode::transcode::<ReservationStatusUpdateRequest>(payload, options)
703 }
704 Action::ReserveNow => crate::decode::transcode::<ReserveNowRequest>(payload, options),
705 Action::Reset => crate::decode::transcode::<ResetRequest>(payload, options),
706 Action::SecurityEventNotification => {
707 crate::decode::transcode::<SecurityEventNotificationRequest>(payload, options)
708 }
709 Action::SendLocalList => crate::decode::transcode::<SendLocalListRequest>(payload, options),
710 Action::SetChargingProfile => {
711 crate::decode::transcode::<SetChargingProfileRequest>(payload, options)
712 }
713 Action::SetDisplayMessage => {
714 crate::decode::transcode::<SetDisplayMessageRequest>(payload, options)
715 }
716 Action::SetMonitoringBase => {
717 crate::decode::transcode::<SetMonitoringBaseRequest>(payload, options)
718 }
719 Action::SetMonitoringLevel => {
720 crate::decode::transcode::<SetMonitoringLevelRequest>(payload, options)
721 }
722 Action::SetNetworkProfile => {
723 crate::decode::transcode::<SetNetworkProfileRequest>(payload, options)
724 }
725 Action::SetVariableMonitoring => {
726 crate::decode::transcode::<SetVariableMonitoringRequest>(payload, options)
727 }
728 Action::SetVariables => crate::decode::transcode::<SetVariablesRequest>(payload, options),
729 Action::SignCertificate => {
730 crate::decode::transcode::<SignCertificateRequest>(payload, options)
731 }
732 Action::StatusNotification => {
733 crate::decode::transcode::<StatusNotificationRequest>(payload, options)
734 }
735 Action::TransactionEvent => {
736 crate::decode::transcode::<TransactionEventRequest>(payload, options)
737 }
738 Action::TriggerMessage => {
739 crate::decode::transcode::<TriggerMessageRequest>(payload, options)
740 }
741 Action::UnlockConnector => {
742 crate::decode::transcode::<UnlockConnectorRequest>(payload, options)
743 }
744 Action::UnpublishFirmware => {
745 crate::decode::transcode::<UnpublishFirmwareRequest>(payload, options)
746 }
747 Action::UpdateFirmware => {
748 crate::decode::transcode::<UpdateFirmwareRequest>(payload, options)
749 }
750 }
751}
752
753pub fn transcode_response(
757 action: Action,
758 payload: &RawValue,
759 options: &DecodeOptions,
760) -> Result<alloc::boxed::Box<RawValue>, DecodeError> {
761 match action {
762 Action::Authorize => crate::decode::transcode::<AuthorizeResponse>(payload, options),
763 Action::BootNotification => {
764 crate::decode::transcode::<BootNotificationResponse>(payload, options)
765 }
766 Action::CancelReservation => {
767 crate::decode::transcode::<CancelReservationResponse>(payload, options)
768 }
769 Action::CertificateSigned => {
770 crate::decode::transcode::<CertificateSignedResponse>(payload, options)
771 }
772 Action::ChangeAvailability => {
773 crate::decode::transcode::<ChangeAvailabilityResponse>(payload, options)
774 }
775 Action::ClearCache => crate::decode::transcode::<ClearCacheResponse>(payload, options),
776 Action::ClearChargingProfile => {
777 crate::decode::transcode::<ClearChargingProfileResponse>(payload, options)
778 }
779 Action::ClearDisplayMessage => {
780 crate::decode::transcode::<ClearDisplayMessageResponse>(payload, options)
781 }
782 Action::ClearVariableMonitoring => {
783 crate::decode::transcode::<ClearVariableMonitoringResponse>(payload, options)
784 }
785 Action::ClearedChargingLimit => {
786 crate::decode::transcode::<ClearedChargingLimitResponse>(payload, options)
787 }
788 Action::CostUpdated => crate::decode::transcode::<CostUpdatedResponse>(payload, options),
789 Action::CustomerInformation => {
790 crate::decode::transcode::<CustomerInformationResponse>(payload, options)
791 }
792 Action::DataTransfer => crate::decode::transcode::<DataTransferResponse>(payload, options),
793 Action::DeleteCertificate => {
794 crate::decode::transcode::<DeleteCertificateResponse>(payload, options)
795 }
796 Action::FirmwareStatusNotification => {
797 crate::decode::transcode::<FirmwareStatusNotificationResponse>(payload, options)
798 }
799 Action::Get15118EVCertificate => {
800 crate::decode::transcode::<Get15118EVCertificateResponse>(payload, options)
801 }
802 Action::GetBaseReport => {
803 crate::decode::transcode::<GetBaseReportResponse>(payload, options)
804 }
805 Action::GetCertificateStatus => {
806 crate::decode::transcode::<GetCertificateStatusResponse>(payload, options)
807 }
808 Action::GetChargingProfiles => {
809 crate::decode::transcode::<GetChargingProfilesResponse>(payload, options)
810 }
811 Action::GetCompositeSchedule => {
812 crate::decode::transcode::<GetCompositeScheduleResponse>(payload, options)
813 }
814 Action::GetDisplayMessages => {
815 crate::decode::transcode::<GetDisplayMessagesResponse>(payload, options)
816 }
817 Action::GetInstalledCertificateIds => {
818 crate::decode::transcode::<GetInstalledCertificateIdsResponse>(payload, options)
819 }
820 Action::GetLocalListVersion => {
821 crate::decode::transcode::<GetLocalListVersionResponse>(payload, options)
822 }
823 Action::GetLog => crate::decode::transcode::<GetLogResponse>(payload, options),
824 Action::GetMonitoringReport => {
825 crate::decode::transcode::<GetMonitoringReportResponse>(payload, options)
826 }
827 Action::GetReport => crate::decode::transcode::<GetReportResponse>(payload, options),
828 Action::GetTransactionStatus => {
829 crate::decode::transcode::<GetTransactionStatusResponse>(payload, options)
830 }
831 Action::GetVariables => crate::decode::transcode::<GetVariablesResponse>(payload, options),
832 Action::Heartbeat => crate::decode::transcode::<HeartbeatResponse>(payload, options),
833 Action::InstallCertificate => {
834 crate::decode::transcode::<InstallCertificateResponse>(payload, options)
835 }
836 Action::LogStatusNotification => {
837 crate::decode::transcode::<LogStatusNotificationResponse>(payload, options)
838 }
839 Action::MeterValues => crate::decode::transcode::<MeterValuesResponse>(payload, options),
840 Action::NotifyChargingLimit => {
841 crate::decode::transcode::<NotifyChargingLimitResponse>(payload, options)
842 }
843 Action::NotifyCustomerInformation => {
844 crate::decode::transcode::<NotifyCustomerInformationResponse>(payload, options)
845 }
846 Action::NotifyDisplayMessages => {
847 crate::decode::transcode::<NotifyDisplayMessagesResponse>(payload, options)
848 }
849 Action::NotifyEVChargingNeeds => {
850 crate::decode::transcode::<NotifyEVChargingNeedsResponse>(payload, options)
851 }
852 Action::NotifyEVChargingSchedule => {
853 crate::decode::transcode::<NotifyEVChargingScheduleResponse>(payload, options)
854 }
855 Action::NotifyEvent => crate::decode::transcode::<NotifyEventResponse>(payload, options),
856 Action::NotifyMonitoringReport => {
857 crate::decode::transcode::<NotifyMonitoringReportResponse>(payload, options)
858 }
859 Action::NotifyReport => crate::decode::transcode::<NotifyReportResponse>(payload, options),
860 Action::PublishFirmware => {
861 crate::decode::transcode::<PublishFirmwareResponse>(payload, options)
862 }
863 Action::PublishFirmwareStatusNotification => {
864 crate::decode::transcode::<PublishFirmwareStatusNotificationResponse>(payload, options)
865 }
866 Action::ReportChargingProfiles => {
867 crate::decode::transcode::<ReportChargingProfilesResponse>(payload, options)
868 }
869 Action::RequestStartTransaction => {
870 crate::decode::transcode::<RequestStartTransactionResponse>(payload, options)
871 }
872 Action::RequestStopTransaction => {
873 crate::decode::transcode::<RequestStopTransactionResponse>(payload, options)
874 }
875 Action::ReservationStatusUpdate => {
876 crate::decode::transcode::<ReservationStatusUpdateResponse>(payload, options)
877 }
878 Action::ReserveNow => crate::decode::transcode::<ReserveNowResponse>(payload, options),
879 Action::Reset => crate::decode::transcode::<ResetResponse>(payload, options),
880 Action::SecurityEventNotification => {
881 crate::decode::transcode::<SecurityEventNotificationResponse>(payload, options)
882 }
883 Action::SendLocalList => {
884 crate::decode::transcode::<SendLocalListResponse>(payload, options)
885 }
886 Action::SetChargingProfile => {
887 crate::decode::transcode::<SetChargingProfileResponse>(payload, options)
888 }
889 Action::SetDisplayMessage => {
890 crate::decode::transcode::<SetDisplayMessageResponse>(payload, options)
891 }
892 Action::SetMonitoringBase => {
893 crate::decode::transcode::<SetMonitoringBaseResponse>(payload, options)
894 }
895 Action::SetMonitoringLevel => {
896 crate::decode::transcode::<SetMonitoringLevelResponse>(payload, options)
897 }
898 Action::SetNetworkProfile => {
899 crate::decode::transcode::<SetNetworkProfileResponse>(payload, options)
900 }
901 Action::SetVariableMonitoring => {
902 crate::decode::transcode::<SetVariableMonitoringResponse>(payload, options)
903 }
904 Action::SetVariables => crate::decode::transcode::<SetVariablesResponse>(payload, options),
905 Action::SignCertificate => {
906 crate::decode::transcode::<SignCertificateResponse>(payload, options)
907 }
908 Action::StatusNotification => {
909 crate::decode::transcode::<StatusNotificationResponse>(payload, options)
910 }
911 Action::TransactionEvent => {
912 crate::decode::transcode::<TransactionEventResponse>(payload, options)
913 }
914 Action::TriggerMessage => {
915 crate::decode::transcode::<TriggerMessageResponse>(payload, options)
916 }
917 Action::UnlockConnector => {
918 crate::decode::transcode::<UnlockConnectorResponse>(payload, options)
919 }
920 Action::UnpublishFirmware => {
921 crate::decode::transcode::<UnpublishFirmwareResponse>(payload, options)
922 }
923 Action::UpdateFirmware => {
924 crate::decode::transcode::<UpdateFirmwareResponse>(payload, options)
925 }
926 }
927}
928
929#[derive(Clone, Debug, PartialEq)]
931#[non_exhaustive]
932#[allow(clippy::large_enum_variant)]
933pub enum CsRequest {
934 Authorize(AuthorizeRequest),
936 BootNotification(BootNotificationRequest),
938 ClearedChargingLimit(ClearedChargingLimitRequest),
940 DataTransfer(DataTransferRequest),
942 FirmwareStatusNotification(FirmwareStatusNotificationRequest),
944 Get15118EVCertificate(Get15118EVCertificateRequest),
946 GetCertificateStatus(GetCertificateStatusRequest),
948 Heartbeat(HeartbeatRequest),
950 LogStatusNotification(LogStatusNotificationRequest),
952 MeterValues(MeterValuesRequest),
954 NotifyChargingLimit(NotifyChargingLimitRequest),
956 NotifyCustomerInformation(NotifyCustomerInformationRequest),
958 NotifyDisplayMessages(NotifyDisplayMessagesRequest),
960 NotifyEVChargingNeeds(NotifyEVChargingNeedsRequest),
962 NotifyEVChargingSchedule(NotifyEVChargingScheduleRequest),
964 NotifyEvent(NotifyEventRequest),
966 NotifyMonitoringReport(NotifyMonitoringReportRequest),
968 NotifyReport(NotifyReportRequest),
970 PublishFirmwareStatusNotification(PublishFirmwareStatusNotificationRequest),
972 ReportChargingProfiles(ReportChargingProfilesRequest),
974 ReservationStatusUpdate(ReservationStatusUpdateRequest),
976 SecurityEventNotification(SecurityEventNotificationRequest),
978 SignCertificate(SignCertificateRequest),
980 StatusNotification(StatusNotificationRequest),
982 TransactionEvent(TransactionEventRequest),
984}
985
986impl CsRequest {
987 #[must_use]
989 pub const fn action(&self) -> Action {
990 match self {
991 Self::Authorize(_) => Action::Authorize,
992 Self::BootNotification(_) => Action::BootNotification,
993 Self::ClearedChargingLimit(_) => Action::ClearedChargingLimit,
994 Self::DataTransfer(_) => Action::DataTransfer,
995 Self::FirmwareStatusNotification(_) => Action::FirmwareStatusNotification,
996 Self::Get15118EVCertificate(_) => Action::Get15118EVCertificate,
997 Self::GetCertificateStatus(_) => Action::GetCertificateStatus,
998 Self::Heartbeat(_) => Action::Heartbeat,
999 Self::LogStatusNotification(_) => Action::LogStatusNotification,
1000 Self::MeterValues(_) => Action::MeterValues,
1001 Self::NotifyChargingLimit(_) => Action::NotifyChargingLimit,
1002 Self::NotifyCustomerInformation(_) => Action::NotifyCustomerInformation,
1003 Self::NotifyDisplayMessages(_) => Action::NotifyDisplayMessages,
1004 Self::NotifyEVChargingNeeds(_) => Action::NotifyEVChargingNeeds,
1005 Self::NotifyEVChargingSchedule(_) => Action::NotifyEVChargingSchedule,
1006 Self::NotifyEvent(_) => Action::NotifyEvent,
1007 Self::NotifyMonitoringReport(_) => Action::NotifyMonitoringReport,
1008 Self::NotifyReport(_) => Action::NotifyReport,
1009 Self::PublishFirmwareStatusNotification(_) => Action::PublishFirmwareStatusNotification,
1010 Self::ReportChargingProfiles(_) => Action::ReportChargingProfiles,
1011 Self::ReservationStatusUpdate(_) => Action::ReservationStatusUpdate,
1012 Self::SecurityEventNotification(_) => Action::SecurityEventNotification,
1013 Self::SignCertificate(_) => Action::SignCertificate,
1014 Self::StatusNotification(_) => Action::StatusNotification,
1015 Self::TransactionEvent(_) => Action::TransactionEvent,
1016 }
1017 }
1018
1019 pub fn decode(
1022 action: Action,
1023 payload: &RawValue,
1024 options: &DecodeOptions,
1025 ) -> Result<Self, DecodeError> {
1026 Ok(match action {
1027 Action::Authorize => Self::Authorize(
1028 crate::decode::decode_payload::<AuthorizeRequest>(payload, options)?,
1029 ),
1030 Action::BootNotification => Self::BootNotification(crate::decode::decode_payload::<
1031 BootNotificationRequest,
1032 >(payload, options)?),
1033 Action::ClearedChargingLimit => {
1034 Self::ClearedChargingLimit(crate::decode::decode_payload::<
1035 ClearedChargingLimitRequest,
1036 >(payload, options)?)
1037 }
1038 Action::DataTransfer => Self::DataTransfer(crate::decode::decode_payload::<
1039 DataTransferRequest,
1040 >(payload, options)?),
1041 Action::FirmwareStatusNotification => {
1042 Self::FirmwareStatusNotification(crate::decode::decode_payload::<
1043 FirmwareStatusNotificationRequest,
1044 >(payload, options)?)
1045 }
1046 Action::Get15118EVCertificate => {
1047 Self::Get15118EVCertificate(crate::decode::decode_payload::<
1048 Get15118EVCertificateRequest,
1049 >(payload, options)?)
1050 }
1051 Action::GetCertificateStatus => {
1052 Self::GetCertificateStatus(crate::decode::decode_payload::<
1053 GetCertificateStatusRequest,
1054 >(payload, options)?)
1055 }
1056 Action::Heartbeat => Self::Heartbeat(
1057 crate::decode::decode_payload::<HeartbeatRequest>(payload, options)?,
1058 ),
1059 Action::LogStatusNotification => {
1060 Self::LogStatusNotification(crate::decode::decode_payload::<
1061 LogStatusNotificationRequest,
1062 >(payload, options)?)
1063 }
1064 Action::MeterValues => Self::MeterValues(crate::decode::decode_payload::<
1065 MeterValuesRequest,
1066 >(payload, options)?),
1067 Action::NotifyChargingLimit => {
1068 Self::NotifyChargingLimit(crate::decode::decode_payload::<
1069 NotifyChargingLimitRequest,
1070 >(payload, options)?)
1071 }
1072 Action::NotifyCustomerInformation => {
1073 Self::NotifyCustomerInformation(crate::decode::decode_payload::<
1074 NotifyCustomerInformationRequest,
1075 >(payload, options)?)
1076 }
1077 Action::NotifyDisplayMessages => {
1078 Self::NotifyDisplayMessages(crate::decode::decode_payload::<
1079 NotifyDisplayMessagesRequest,
1080 >(payload, options)?)
1081 }
1082 Action::NotifyEVChargingNeeds => {
1083 Self::NotifyEVChargingNeeds(crate::decode::decode_payload::<
1084 NotifyEVChargingNeedsRequest,
1085 >(payload, options)?)
1086 }
1087 Action::NotifyEVChargingSchedule => {
1088 Self::NotifyEVChargingSchedule(crate::decode::decode_payload::<
1089 NotifyEVChargingScheduleRequest,
1090 >(payload, options)?)
1091 }
1092 Action::NotifyEvent => Self::NotifyEvent(crate::decode::decode_payload::<
1093 NotifyEventRequest,
1094 >(payload, options)?),
1095 Action::NotifyMonitoringReport => {
1096 Self::NotifyMonitoringReport(crate::decode::decode_payload::<
1097 NotifyMonitoringReportRequest,
1098 >(payload, options)?)
1099 }
1100 Action::NotifyReport => Self::NotifyReport(crate::decode::decode_payload::<
1101 NotifyReportRequest,
1102 >(payload, options)?),
1103 Action::PublishFirmwareStatusNotification => {
1104 Self::PublishFirmwareStatusNotification(crate::decode::decode_payload::<
1105 PublishFirmwareStatusNotificationRequest,
1106 >(payload, options)?)
1107 }
1108 Action::ReportChargingProfiles => {
1109 Self::ReportChargingProfiles(crate::decode::decode_payload::<
1110 ReportChargingProfilesRequest,
1111 >(payload, options)?)
1112 }
1113 Action::ReservationStatusUpdate => {
1114 Self::ReservationStatusUpdate(crate::decode::decode_payload::<
1115 ReservationStatusUpdateRequest,
1116 >(payload, options)?)
1117 }
1118 Action::SecurityEventNotification => {
1119 Self::SecurityEventNotification(crate::decode::decode_payload::<
1120 SecurityEventNotificationRequest,
1121 >(payload, options)?)
1122 }
1123 Action::SignCertificate => Self::SignCertificate(crate::decode::decode_payload::<
1124 SignCertificateRequest,
1125 >(payload, options)?),
1126 Action::StatusNotification => Self::StatusNotification(
1127 crate::decode::decode_payload::<StatusNotificationRequest>(payload, options)?,
1128 ),
1129 Action::TransactionEvent => Self::TransactionEvent(crate::decode::decode_payload::<
1130 TransactionEventRequest,
1131 >(payload, options)?),
1132 other => return Err(DecodeError::unsupported_action(other.as_str())),
1133 })
1134 }
1135
1136 pub fn to_json(&self) -> Result<alloc::string::String, serde_json::Error> {
1138 match self {
1139 Self::Authorize(p) => serde_json::to_string(p),
1140 Self::BootNotification(p) => serde_json::to_string(p),
1141 Self::ClearedChargingLimit(p) => serde_json::to_string(p),
1142 Self::DataTransfer(p) => serde_json::to_string(p),
1143 Self::FirmwareStatusNotification(p) => serde_json::to_string(p),
1144 Self::Get15118EVCertificate(p) => serde_json::to_string(p),
1145 Self::GetCertificateStatus(p) => serde_json::to_string(p),
1146 Self::Heartbeat(p) => serde_json::to_string(p),
1147 Self::LogStatusNotification(p) => serde_json::to_string(p),
1148 Self::MeterValues(p) => serde_json::to_string(p),
1149 Self::NotifyChargingLimit(p) => serde_json::to_string(p),
1150 Self::NotifyCustomerInformation(p) => serde_json::to_string(p),
1151 Self::NotifyDisplayMessages(p) => serde_json::to_string(p),
1152 Self::NotifyEVChargingNeeds(p) => serde_json::to_string(p),
1153 Self::NotifyEVChargingSchedule(p) => serde_json::to_string(p),
1154 Self::NotifyEvent(p) => serde_json::to_string(p),
1155 Self::NotifyMonitoringReport(p) => serde_json::to_string(p),
1156 Self::NotifyReport(p) => serde_json::to_string(p),
1157 Self::PublishFirmwareStatusNotification(p) => serde_json::to_string(p),
1158 Self::ReportChargingProfiles(p) => serde_json::to_string(p),
1159 Self::ReservationStatusUpdate(p) => serde_json::to_string(p),
1160 Self::SecurityEventNotification(p) => serde_json::to_string(p),
1161 Self::SignCertificate(p) => serde_json::to_string(p),
1162 Self::StatusNotification(p) => serde_json::to_string(p),
1163 Self::TransactionEvent(p) => serde_json::to_string(p),
1164 }
1165 }
1166}
1167
1168impl Validate for CsRequest {
1169 fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
1170 match self {
1171 Self::Authorize(p) => p.validate_at(path, out),
1172 Self::BootNotification(p) => p.validate_at(path, out),
1173 Self::ClearedChargingLimit(p) => p.validate_at(path, out),
1174 Self::DataTransfer(p) => p.validate_at(path, out),
1175 Self::FirmwareStatusNotification(p) => p.validate_at(path, out),
1176 Self::Get15118EVCertificate(p) => p.validate_at(path, out),
1177 Self::GetCertificateStatus(p) => p.validate_at(path, out),
1178 Self::Heartbeat(p) => p.validate_at(path, out),
1179 Self::LogStatusNotification(p) => p.validate_at(path, out),
1180 Self::MeterValues(p) => p.validate_at(path, out),
1181 Self::NotifyChargingLimit(p) => p.validate_at(path, out),
1182 Self::NotifyCustomerInformation(p) => p.validate_at(path, out),
1183 Self::NotifyDisplayMessages(p) => p.validate_at(path, out),
1184 Self::NotifyEVChargingNeeds(p) => p.validate_at(path, out),
1185 Self::NotifyEVChargingSchedule(p) => p.validate_at(path, out),
1186 Self::NotifyEvent(p) => p.validate_at(path, out),
1187 Self::NotifyMonitoringReport(p) => p.validate_at(path, out),
1188 Self::NotifyReport(p) => p.validate_at(path, out),
1189 Self::PublishFirmwareStatusNotification(p) => p.validate_at(path, out),
1190 Self::ReportChargingProfiles(p) => p.validate_at(path, out),
1191 Self::ReservationStatusUpdate(p) => p.validate_at(path, out),
1192 Self::SecurityEventNotification(p) => p.validate_at(path, out),
1193 Self::SignCertificate(p) => p.validate_at(path, out),
1194 Self::StatusNotification(p) => p.validate_at(path, out),
1195 Self::TransactionEvent(p) => p.validate_at(path, out),
1196 }
1197 }
1198}
1199
1200impl serde::Serialize for CsRequest {
1201 fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
1202 match self {
1203 Self::Authorize(p) => p.serialize(ser),
1204 Self::BootNotification(p) => p.serialize(ser),
1205 Self::ClearedChargingLimit(p) => p.serialize(ser),
1206 Self::DataTransfer(p) => p.serialize(ser),
1207 Self::FirmwareStatusNotification(p) => p.serialize(ser),
1208 Self::Get15118EVCertificate(p) => p.serialize(ser),
1209 Self::GetCertificateStatus(p) => p.serialize(ser),
1210 Self::Heartbeat(p) => p.serialize(ser),
1211 Self::LogStatusNotification(p) => p.serialize(ser),
1212 Self::MeterValues(p) => p.serialize(ser),
1213 Self::NotifyChargingLimit(p) => p.serialize(ser),
1214 Self::NotifyCustomerInformation(p) => p.serialize(ser),
1215 Self::NotifyDisplayMessages(p) => p.serialize(ser),
1216 Self::NotifyEVChargingNeeds(p) => p.serialize(ser),
1217 Self::NotifyEVChargingSchedule(p) => p.serialize(ser),
1218 Self::NotifyEvent(p) => p.serialize(ser),
1219 Self::NotifyMonitoringReport(p) => p.serialize(ser),
1220 Self::NotifyReport(p) => p.serialize(ser),
1221 Self::PublishFirmwareStatusNotification(p) => p.serialize(ser),
1222 Self::ReportChargingProfiles(p) => p.serialize(ser),
1223 Self::ReservationStatusUpdate(p) => p.serialize(ser),
1224 Self::SecurityEventNotification(p) => p.serialize(ser),
1225 Self::SignCertificate(p) => p.serialize(ser),
1226 Self::StatusNotification(p) => p.serialize(ser),
1227 Self::TransactionEvent(p) => p.serialize(ser),
1228 }
1229 }
1230}
1231
1232#[derive(Clone, Debug, PartialEq)]
1236#[non_exhaustive]
1237#[allow(clippy::large_enum_variant)]
1238pub enum CsResponse {
1239 Authorize(AuthorizeResponse),
1241 BootNotification(BootNotificationResponse),
1243 ClearedChargingLimit(ClearedChargingLimitResponse),
1245 DataTransfer(DataTransferResponse),
1247 FirmwareStatusNotification(FirmwareStatusNotificationResponse),
1249 Get15118EVCertificate(Get15118EVCertificateResponse),
1251 GetCertificateStatus(GetCertificateStatusResponse),
1253 Heartbeat(HeartbeatResponse),
1255 LogStatusNotification(LogStatusNotificationResponse),
1257 MeterValues(MeterValuesResponse),
1259 NotifyChargingLimit(NotifyChargingLimitResponse),
1261 NotifyCustomerInformation(NotifyCustomerInformationResponse),
1263 NotifyDisplayMessages(NotifyDisplayMessagesResponse),
1265 NotifyEVChargingNeeds(NotifyEVChargingNeedsResponse),
1267 NotifyEVChargingSchedule(NotifyEVChargingScheduleResponse),
1269 NotifyEvent(NotifyEventResponse),
1271 NotifyMonitoringReport(NotifyMonitoringReportResponse),
1273 NotifyReport(NotifyReportResponse),
1275 PublishFirmwareStatusNotification(PublishFirmwareStatusNotificationResponse),
1277 ReportChargingProfiles(ReportChargingProfilesResponse),
1279 ReservationStatusUpdate(ReservationStatusUpdateResponse),
1281 SecurityEventNotification(SecurityEventNotificationResponse),
1283 SignCertificate(SignCertificateResponse),
1285 StatusNotification(StatusNotificationResponse),
1287 TransactionEvent(TransactionEventResponse),
1289}
1290
1291impl CsResponse {
1292 #[must_use]
1294 pub const fn action(&self) -> Action {
1295 match self {
1296 Self::Authorize(_) => Action::Authorize,
1297 Self::BootNotification(_) => Action::BootNotification,
1298 Self::ClearedChargingLimit(_) => Action::ClearedChargingLimit,
1299 Self::DataTransfer(_) => Action::DataTransfer,
1300 Self::FirmwareStatusNotification(_) => Action::FirmwareStatusNotification,
1301 Self::Get15118EVCertificate(_) => Action::Get15118EVCertificate,
1302 Self::GetCertificateStatus(_) => Action::GetCertificateStatus,
1303 Self::Heartbeat(_) => Action::Heartbeat,
1304 Self::LogStatusNotification(_) => Action::LogStatusNotification,
1305 Self::MeterValues(_) => Action::MeterValues,
1306 Self::NotifyChargingLimit(_) => Action::NotifyChargingLimit,
1307 Self::NotifyCustomerInformation(_) => Action::NotifyCustomerInformation,
1308 Self::NotifyDisplayMessages(_) => Action::NotifyDisplayMessages,
1309 Self::NotifyEVChargingNeeds(_) => Action::NotifyEVChargingNeeds,
1310 Self::NotifyEVChargingSchedule(_) => Action::NotifyEVChargingSchedule,
1311 Self::NotifyEvent(_) => Action::NotifyEvent,
1312 Self::NotifyMonitoringReport(_) => Action::NotifyMonitoringReport,
1313 Self::NotifyReport(_) => Action::NotifyReport,
1314 Self::PublishFirmwareStatusNotification(_) => Action::PublishFirmwareStatusNotification,
1315 Self::ReportChargingProfiles(_) => Action::ReportChargingProfiles,
1316 Self::ReservationStatusUpdate(_) => Action::ReservationStatusUpdate,
1317 Self::SecurityEventNotification(_) => Action::SecurityEventNotification,
1318 Self::SignCertificate(_) => Action::SignCertificate,
1319 Self::StatusNotification(_) => Action::StatusNotification,
1320 Self::TransactionEvent(_) => Action::TransactionEvent,
1321 }
1322 }
1323
1324 pub fn decode(
1327 action: Action,
1328 payload: &RawValue,
1329 options: &DecodeOptions,
1330 ) -> Result<Self, DecodeError> {
1331 Ok(match action {
1332 Action::Authorize => Self::Authorize(
1333 crate::decode::decode_payload::<AuthorizeResponse>(payload, options)?,
1334 ),
1335 Action::BootNotification => Self::BootNotification(crate::decode::decode_payload::<
1336 BootNotificationResponse,
1337 >(payload, options)?),
1338 Action::ClearedChargingLimit => {
1339 Self::ClearedChargingLimit(crate::decode::decode_payload::<
1340 ClearedChargingLimitResponse,
1341 >(payload, options)?)
1342 }
1343 Action::DataTransfer => Self::DataTransfer(crate::decode::decode_payload::<
1344 DataTransferResponse,
1345 >(payload, options)?),
1346 Action::FirmwareStatusNotification => {
1347 Self::FirmwareStatusNotification(crate::decode::decode_payload::<
1348 FirmwareStatusNotificationResponse,
1349 >(payload, options)?)
1350 }
1351 Action::Get15118EVCertificate => {
1352 Self::Get15118EVCertificate(crate::decode::decode_payload::<
1353 Get15118EVCertificateResponse,
1354 >(payload, options)?)
1355 }
1356 Action::GetCertificateStatus => {
1357 Self::GetCertificateStatus(crate::decode::decode_payload::<
1358 GetCertificateStatusResponse,
1359 >(payload, options)?)
1360 }
1361 Action::Heartbeat => Self::Heartbeat(
1362 crate::decode::decode_payload::<HeartbeatResponse>(payload, options)?,
1363 ),
1364 Action::LogStatusNotification => {
1365 Self::LogStatusNotification(crate::decode::decode_payload::<
1366 LogStatusNotificationResponse,
1367 >(payload, options)?)
1368 }
1369 Action::MeterValues => Self::MeterValues(crate::decode::decode_payload::<
1370 MeterValuesResponse,
1371 >(payload, options)?),
1372 Action::NotifyChargingLimit => {
1373 Self::NotifyChargingLimit(crate::decode::decode_payload::<
1374 NotifyChargingLimitResponse,
1375 >(payload, options)?)
1376 }
1377 Action::NotifyCustomerInformation => {
1378 Self::NotifyCustomerInformation(crate::decode::decode_payload::<
1379 NotifyCustomerInformationResponse,
1380 >(payload, options)?)
1381 }
1382 Action::NotifyDisplayMessages => {
1383 Self::NotifyDisplayMessages(crate::decode::decode_payload::<
1384 NotifyDisplayMessagesResponse,
1385 >(payload, options)?)
1386 }
1387 Action::NotifyEVChargingNeeds => {
1388 Self::NotifyEVChargingNeeds(crate::decode::decode_payload::<
1389 NotifyEVChargingNeedsResponse,
1390 >(payload, options)?)
1391 }
1392 Action::NotifyEVChargingSchedule => {
1393 Self::NotifyEVChargingSchedule(crate::decode::decode_payload::<
1394 NotifyEVChargingScheduleResponse,
1395 >(payload, options)?)
1396 }
1397 Action::NotifyEvent => Self::NotifyEvent(crate::decode::decode_payload::<
1398 NotifyEventResponse,
1399 >(payload, options)?),
1400 Action::NotifyMonitoringReport => {
1401 Self::NotifyMonitoringReport(crate::decode::decode_payload::<
1402 NotifyMonitoringReportResponse,
1403 >(payload, options)?)
1404 }
1405 Action::NotifyReport => Self::NotifyReport(crate::decode::decode_payload::<
1406 NotifyReportResponse,
1407 >(payload, options)?),
1408 Action::PublishFirmwareStatusNotification => {
1409 Self::PublishFirmwareStatusNotification(crate::decode::decode_payload::<
1410 PublishFirmwareStatusNotificationResponse,
1411 >(payload, options)?)
1412 }
1413 Action::ReportChargingProfiles => {
1414 Self::ReportChargingProfiles(crate::decode::decode_payload::<
1415 ReportChargingProfilesResponse,
1416 >(payload, options)?)
1417 }
1418 Action::ReservationStatusUpdate => {
1419 Self::ReservationStatusUpdate(crate::decode::decode_payload::<
1420 ReservationStatusUpdateResponse,
1421 >(payload, options)?)
1422 }
1423 Action::SecurityEventNotification => {
1424 Self::SecurityEventNotification(crate::decode::decode_payload::<
1425 SecurityEventNotificationResponse,
1426 >(payload, options)?)
1427 }
1428 Action::SignCertificate => Self::SignCertificate(crate::decode::decode_payload::<
1429 SignCertificateResponse,
1430 >(payload, options)?),
1431 Action::StatusNotification => Self::StatusNotification(
1432 crate::decode::decode_payload::<StatusNotificationResponse>(payload, options)?,
1433 ),
1434 Action::TransactionEvent => Self::TransactionEvent(crate::decode::decode_payload::<
1435 TransactionEventResponse,
1436 >(payload, options)?),
1437 other => return Err(DecodeError::unsupported_action(other.as_str())),
1438 })
1439 }
1440
1441 pub fn to_json(&self) -> Result<alloc::string::String, serde_json::Error> {
1443 match self {
1444 Self::Authorize(p) => serde_json::to_string(p),
1445 Self::BootNotification(p) => serde_json::to_string(p),
1446 Self::ClearedChargingLimit(p) => serde_json::to_string(p),
1447 Self::DataTransfer(p) => serde_json::to_string(p),
1448 Self::FirmwareStatusNotification(p) => serde_json::to_string(p),
1449 Self::Get15118EVCertificate(p) => serde_json::to_string(p),
1450 Self::GetCertificateStatus(p) => serde_json::to_string(p),
1451 Self::Heartbeat(p) => serde_json::to_string(p),
1452 Self::LogStatusNotification(p) => serde_json::to_string(p),
1453 Self::MeterValues(p) => serde_json::to_string(p),
1454 Self::NotifyChargingLimit(p) => serde_json::to_string(p),
1455 Self::NotifyCustomerInformation(p) => serde_json::to_string(p),
1456 Self::NotifyDisplayMessages(p) => serde_json::to_string(p),
1457 Self::NotifyEVChargingNeeds(p) => serde_json::to_string(p),
1458 Self::NotifyEVChargingSchedule(p) => serde_json::to_string(p),
1459 Self::NotifyEvent(p) => serde_json::to_string(p),
1460 Self::NotifyMonitoringReport(p) => serde_json::to_string(p),
1461 Self::NotifyReport(p) => serde_json::to_string(p),
1462 Self::PublishFirmwareStatusNotification(p) => serde_json::to_string(p),
1463 Self::ReportChargingProfiles(p) => serde_json::to_string(p),
1464 Self::ReservationStatusUpdate(p) => serde_json::to_string(p),
1465 Self::SecurityEventNotification(p) => serde_json::to_string(p),
1466 Self::SignCertificate(p) => serde_json::to_string(p),
1467 Self::StatusNotification(p) => serde_json::to_string(p),
1468 Self::TransactionEvent(p) => serde_json::to_string(p),
1469 }
1470 }
1471}
1472
1473impl Validate for CsResponse {
1474 fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
1475 match self {
1476 Self::Authorize(p) => p.validate_at(path, out),
1477 Self::BootNotification(p) => p.validate_at(path, out),
1478 Self::ClearedChargingLimit(p) => p.validate_at(path, out),
1479 Self::DataTransfer(p) => p.validate_at(path, out),
1480 Self::FirmwareStatusNotification(p) => p.validate_at(path, out),
1481 Self::Get15118EVCertificate(p) => p.validate_at(path, out),
1482 Self::GetCertificateStatus(p) => p.validate_at(path, out),
1483 Self::Heartbeat(p) => p.validate_at(path, out),
1484 Self::LogStatusNotification(p) => p.validate_at(path, out),
1485 Self::MeterValues(p) => p.validate_at(path, out),
1486 Self::NotifyChargingLimit(p) => p.validate_at(path, out),
1487 Self::NotifyCustomerInformation(p) => p.validate_at(path, out),
1488 Self::NotifyDisplayMessages(p) => p.validate_at(path, out),
1489 Self::NotifyEVChargingNeeds(p) => p.validate_at(path, out),
1490 Self::NotifyEVChargingSchedule(p) => p.validate_at(path, out),
1491 Self::NotifyEvent(p) => p.validate_at(path, out),
1492 Self::NotifyMonitoringReport(p) => p.validate_at(path, out),
1493 Self::NotifyReport(p) => p.validate_at(path, out),
1494 Self::PublishFirmwareStatusNotification(p) => p.validate_at(path, out),
1495 Self::ReportChargingProfiles(p) => p.validate_at(path, out),
1496 Self::ReservationStatusUpdate(p) => p.validate_at(path, out),
1497 Self::SecurityEventNotification(p) => p.validate_at(path, out),
1498 Self::SignCertificate(p) => p.validate_at(path, out),
1499 Self::StatusNotification(p) => p.validate_at(path, out),
1500 Self::TransactionEvent(p) => p.validate_at(path, out),
1501 }
1502 }
1503}
1504
1505impl serde::Serialize for CsResponse {
1506 fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
1507 match self {
1508 Self::Authorize(p) => p.serialize(ser),
1509 Self::BootNotification(p) => p.serialize(ser),
1510 Self::ClearedChargingLimit(p) => p.serialize(ser),
1511 Self::DataTransfer(p) => p.serialize(ser),
1512 Self::FirmwareStatusNotification(p) => p.serialize(ser),
1513 Self::Get15118EVCertificate(p) => p.serialize(ser),
1514 Self::GetCertificateStatus(p) => p.serialize(ser),
1515 Self::Heartbeat(p) => p.serialize(ser),
1516 Self::LogStatusNotification(p) => p.serialize(ser),
1517 Self::MeterValues(p) => p.serialize(ser),
1518 Self::NotifyChargingLimit(p) => p.serialize(ser),
1519 Self::NotifyCustomerInformation(p) => p.serialize(ser),
1520 Self::NotifyDisplayMessages(p) => p.serialize(ser),
1521 Self::NotifyEVChargingNeeds(p) => p.serialize(ser),
1522 Self::NotifyEVChargingSchedule(p) => p.serialize(ser),
1523 Self::NotifyEvent(p) => p.serialize(ser),
1524 Self::NotifyMonitoringReport(p) => p.serialize(ser),
1525 Self::NotifyReport(p) => p.serialize(ser),
1526 Self::PublishFirmwareStatusNotification(p) => p.serialize(ser),
1527 Self::ReportChargingProfiles(p) => p.serialize(ser),
1528 Self::ReservationStatusUpdate(p) => p.serialize(ser),
1529 Self::SecurityEventNotification(p) => p.serialize(ser),
1530 Self::SignCertificate(p) => p.serialize(ser),
1531 Self::StatusNotification(p) => p.serialize(ser),
1532 Self::TransactionEvent(p) => p.serialize(ser),
1533 }
1534 }
1535}
1536
1537#[derive(Clone, Debug, PartialEq)]
1539#[non_exhaustive]
1540#[allow(clippy::large_enum_variant)]
1541pub enum CsmsRequest {
1542 CancelReservation(CancelReservationRequest),
1544 CertificateSigned(CertificateSignedRequest),
1546 ChangeAvailability(ChangeAvailabilityRequest),
1548 ClearCache(ClearCacheRequest),
1550 ClearChargingProfile(ClearChargingProfileRequest),
1552 ClearDisplayMessage(ClearDisplayMessageRequest),
1554 ClearVariableMonitoring(ClearVariableMonitoringRequest),
1556 CostUpdated(CostUpdatedRequest),
1558 CustomerInformation(CustomerInformationRequest),
1560 DataTransfer(DataTransferRequest),
1562 DeleteCertificate(DeleteCertificateRequest),
1564 GetBaseReport(GetBaseReportRequest),
1566 GetChargingProfiles(GetChargingProfilesRequest),
1568 GetCompositeSchedule(GetCompositeScheduleRequest),
1570 GetDisplayMessages(GetDisplayMessagesRequest),
1572 GetInstalledCertificateIds(GetInstalledCertificateIdsRequest),
1574 GetLocalListVersion(GetLocalListVersionRequest),
1576 GetLog(GetLogRequest),
1578 GetMonitoringReport(GetMonitoringReportRequest),
1580 GetReport(GetReportRequest),
1582 GetTransactionStatus(GetTransactionStatusRequest),
1584 GetVariables(GetVariablesRequest),
1586 InstallCertificate(InstallCertificateRequest),
1588 PublishFirmware(PublishFirmwareRequest),
1590 RequestStartTransaction(RequestStartTransactionRequest),
1592 RequestStopTransaction(RequestStopTransactionRequest),
1594 ReserveNow(ReserveNowRequest),
1596 Reset(ResetRequest),
1598 SendLocalList(SendLocalListRequest),
1600 SetChargingProfile(SetChargingProfileRequest),
1602 SetDisplayMessage(SetDisplayMessageRequest),
1604 SetMonitoringBase(SetMonitoringBaseRequest),
1606 SetMonitoringLevel(SetMonitoringLevelRequest),
1608 SetNetworkProfile(SetNetworkProfileRequest),
1610 SetVariableMonitoring(SetVariableMonitoringRequest),
1612 SetVariables(SetVariablesRequest),
1614 TriggerMessage(TriggerMessageRequest),
1616 UnlockConnector(UnlockConnectorRequest),
1618 UnpublishFirmware(UnpublishFirmwareRequest),
1620 UpdateFirmware(UpdateFirmwareRequest),
1622}
1623
1624impl CsmsRequest {
1625 #[must_use]
1627 pub const fn action(&self) -> Action {
1628 match self {
1629 Self::CancelReservation(_) => Action::CancelReservation,
1630 Self::CertificateSigned(_) => Action::CertificateSigned,
1631 Self::ChangeAvailability(_) => Action::ChangeAvailability,
1632 Self::ClearCache(_) => Action::ClearCache,
1633 Self::ClearChargingProfile(_) => Action::ClearChargingProfile,
1634 Self::ClearDisplayMessage(_) => Action::ClearDisplayMessage,
1635 Self::ClearVariableMonitoring(_) => Action::ClearVariableMonitoring,
1636 Self::CostUpdated(_) => Action::CostUpdated,
1637 Self::CustomerInformation(_) => Action::CustomerInformation,
1638 Self::DataTransfer(_) => Action::DataTransfer,
1639 Self::DeleteCertificate(_) => Action::DeleteCertificate,
1640 Self::GetBaseReport(_) => Action::GetBaseReport,
1641 Self::GetChargingProfiles(_) => Action::GetChargingProfiles,
1642 Self::GetCompositeSchedule(_) => Action::GetCompositeSchedule,
1643 Self::GetDisplayMessages(_) => Action::GetDisplayMessages,
1644 Self::GetInstalledCertificateIds(_) => Action::GetInstalledCertificateIds,
1645 Self::GetLocalListVersion(_) => Action::GetLocalListVersion,
1646 Self::GetLog(_) => Action::GetLog,
1647 Self::GetMonitoringReport(_) => Action::GetMonitoringReport,
1648 Self::GetReport(_) => Action::GetReport,
1649 Self::GetTransactionStatus(_) => Action::GetTransactionStatus,
1650 Self::GetVariables(_) => Action::GetVariables,
1651 Self::InstallCertificate(_) => Action::InstallCertificate,
1652 Self::PublishFirmware(_) => Action::PublishFirmware,
1653 Self::RequestStartTransaction(_) => Action::RequestStartTransaction,
1654 Self::RequestStopTransaction(_) => Action::RequestStopTransaction,
1655 Self::ReserveNow(_) => Action::ReserveNow,
1656 Self::Reset(_) => Action::Reset,
1657 Self::SendLocalList(_) => Action::SendLocalList,
1658 Self::SetChargingProfile(_) => Action::SetChargingProfile,
1659 Self::SetDisplayMessage(_) => Action::SetDisplayMessage,
1660 Self::SetMonitoringBase(_) => Action::SetMonitoringBase,
1661 Self::SetMonitoringLevel(_) => Action::SetMonitoringLevel,
1662 Self::SetNetworkProfile(_) => Action::SetNetworkProfile,
1663 Self::SetVariableMonitoring(_) => Action::SetVariableMonitoring,
1664 Self::SetVariables(_) => Action::SetVariables,
1665 Self::TriggerMessage(_) => Action::TriggerMessage,
1666 Self::UnlockConnector(_) => Action::UnlockConnector,
1667 Self::UnpublishFirmware(_) => Action::UnpublishFirmware,
1668 Self::UpdateFirmware(_) => Action::UpdateFirmware,
1669 }
1670 }
1671
1672 pub fn decode(
1675 action: Action,
1676 payload: &RawValue,
1677 options: &DecodeOptions,
1678 ) -> Result<Self, DecodeError> {
1679 Ok(match action {
1680 Action::CancelReservation => Self::CancelReservation(crate::decode::decode_payload::<
1681 CancelReservationRequest,
1682 >(payload, options)?),
1683 Action::CertificateSigned => Self::CertificateSigned(crate::decode::decode_payload::<
1684 CertificateSignedRequest,
1685 >(payload, options)?),
1686 Action::ChangeAvailability => Self::ChangeAvailability(
1687 crate::decode::decode_payload::<ChangeAvailabilityRequest>(payload, options)?,
1688 ),
1689 Action::ClearCache => Self::ClearCache(crate::decode::decode_payload::<
1690 ClearCacheRequest,
1691 >(payload, options)?),
1692 Action::ClearChargingProfile => {
1693 Self::ClearChargingProfile(crate::decode::decode_payload::<
1694 ClearChargingProfileRequest,
1695 >(payload, options)?)
1696 }
1697 Action::ClearDisplayMessage => {
1698 Self::ClearDisplayMessage(crate::decode::decode_payload::<
1699 ClearDisplayMessageRequest,
1700 >(payload, options)?)
1701 }
1702 Action::ClearVariableMonitoring => {
1703 Self::ClearVariableMonitoring(crate::decode::decode_payload::<
1704 ClearVariableMonitoringRequest,
1705 >(payload, options)?)
1706 }
1707 Action::CostUpdated => Self::CostUpdated(crate::decode::decode_payload::<
1708 CostUpdatedRequest,
1709 >(payload, options)?),
1710 Action::CustomerInformation => {
1711 Self::CustomerInformation(crate::decode::decode_payload::<
1712 CustomerInformationRequest,
1713 >(payload, options)?)
1714 }
1715 Action::DataTransfer => Self::DataTransfer(crate::decode::decode_payload::<
1716 DataTransferRequest,
1717 >(payload, options)?),
1718 Action::DeleteCertificate => Self::DeleteCertificate(crate::decode::decode_payload::<
1719 DeleteCertificateRequest,
1720 >(payload, options)?),
1721 Action::GetBaseReport => Self::GetBaseReport(crate::decode::decode_payload::<
1722 GetBaseReportRequest,
1723 >(payload, options)?),
1724 Action::GetChargingProfiles => {
1725 Self::GetChargingProfiles(crate::decode::decode_payload::<
1726 GetChargingProfilesRequest,
1727 >(payload, options)?)
1728 }
1729 Action::GetCompositeSchedule => {
1730 Self::GetCompositeSchedule(crate::decode::decode_payload::<
1731 GetCompositeScheduleRequest,
1732 >(payload, options)?)
1733 }
1734 Action::GetDisplayMessages => Self::GetDisplayMessages(
1735 crate::decode::decode_payload::<GetDisplayMessagesRequest>(payload, options)?,
1736 ),
1737 Action::GetInstalledCertificateIds => {
1738 Self::GetInstalledCertificateIds(crate::decode::decode_payload::<
1739 GetInstalledCertificateIdsRequest,
1740 >(payload, options)?)
1741 }
1742 Action::GetLocalListVersion => {
1743 Self::GetLocalListVersion(crate::decode::decode_payload::<
1744 GetLocalListVersionRequest,
1745 >(payload, options)?)
1746 }
1747 Action::GetLog => Self::GetLog(crate::decode::decode_payload::<GetLogRequest>(
1748 payload, options,
1749 )?),
1750 Action::GetMonitoringReport => {
1751 Self::GetMonitoringReport(crate::decode::decode_payload::<
1752 GetMonitoringReportRequest,
1753 >(payload, options)?)
1754 }
1755 Action::GetReport => Self::GetReport(
1756 crate::decode::decode_payload::<GetReportRequest>(payload, options)?,
1757 ),
1758 Action::GetTransactionStatus => {
1759 Self::GetTransactionStatus(crate::decode::decode_payload::<
1760 GetTransactionStatusRequest,
1761 >(payload, options)?)
1762 }
1763 Action::GetVariables => Self::GetVariables(crate::decode::decode_payload::<
1764 GetVariablesRequest,
1765 >(payload, options)?),
1766 Action::InstallCertificate => Self::InstallCertificate(
1767 crate::decode::decode_payload::<InstallCertificateRequest>(payload, options)?,
1768 ),
1769 Action::PublishFirmware => Self::PublishFirmware(crate::decode::decode_payload::<
1770 PublishFirmwareRequest,
1771 >(payload, options)?),
1772 Action::RequestStartTransaction => {
1773 Self::RequestStartTransaction(crate::decode::decode_payload::<
1774 RequestStartTransactionRequest,
1775 >(payload, options)?)
1776 }
1777 Action::RequestStopTransaction => {
1778 Self::RequestStopTransaction(crate::decode::decode_payload::<
1779 RequestStopTransactionRequest,
1780 >(payload, options)?)
1781 }
1782 Action::ReserveNow => Self::ReserveNow(crate::decode::decode_payload::<
1783 ReserveNowRequest,
1784 >(payload, options)?),
1785 Action::Reset => Self::Reset(crate::decode::decode_payload::<ResetRequest>(
1786 payload, options,
1787 )?),
1788 Action::SendLocalList => Self::SendLocalList(crate::decode::decode_payload::<
1789 SendLocalListRequest,
1790 >(payload, options)?),
1791 Action::SetChargingProfile => Self::SetChargingProfile(
1792 crate::decode::decode_payload::<SetChargingProfileRequest>(payload, options)?,
1793 ),
1794 Action::SetDisplayMessage => Self::SetDisplayMessage(crate::decode::decode_payload::<
1795 SetDisplayMessageRequest,
1796 >(payload, options)?),
1797 Action::SetMonitoringBase => Self::SetMonitoringBase(crate::decode::decode_payload::<
1798 SetMonitoringBaseRequest,
1799 >(payload, options)?),
1800 Action::SetMonitoringLevel => Self::SetMonitoringLevel(
1801 crate::decode::decode_payload::<SetMonitoringLevelRequest>(payload, options)?,
1802 ),
1803 Action::SetNetworkProfile => Self::SetNetworkProfile(crate::decode::decode_payload::<
1804 SetNetworkProfileRequest,
1805 >(payload, options)?),
1806 Action::SetVariableMonitoring => {
1807 Self::SetVariableMonitoring(crate::decode::decode_payload::<
1808 SetVariableMonitoringRequest,
1809 >(payload, options)?)
1810 }
1811 Action::SetVariables => Self::SetVariables(crate::decode::decode_payload::<
1812 SetVariablesRequest,
1813 >(payload, options)?),
1814 Action::TriggerMessage => Self::TriggerMessage(crate::decode::decode_payload::<
1815 TriggerMessageRequest,
1816 >(payload, options)?),
1817 Action::UnlockConnector => Self::UnlockConnector(crate::decode::decode_payload::<
1818 UnlockConnectorRequest,
1819 >(payload, options)?),
1820 Action::UnpublishFirmware => Self::UnpublishFirmware(crate::decode::decode_payload::<
1821 UnpublishFirmwareRequest,
1822 >(payload, options)?),
1823 Action::UpdateFirmware => Self::UpdateFirmware(crate::decode::decode_payload::<
1824 UpdateFirmwareRequest,
1825 >(payload, options)?),
1826 other => return Err(DecodeError::unsupported_action(other.as_str())),
1827 })
1828 }
1829
1830 pub fn to_json(&self) -> Result<alloc::string::String, serde_json::Error> {
1832 match self {
1833 Self::CancelReservation(p) => serde_json::to_string(p),
1834 Self::CertificateSigned(p) => serde_json::to_string(p),
1835 Self::ChangeAvailability(p) => serde_json::to_string(p),
1836 Self::ClearCache(p) => serde_json::to_string(p),
1837 Self::ClearChargingProfile(p) => serde_json::to_string(p),
1838 Self::ClearDisplayMessage(p) => serde_json::to_string(p),
1839 Self::ClearVariableMonitoring(p) => serde_json::to_string(p),
1840 Self::CostUpdated(p) => serde_json::to_string(p),
1841 Self::CustomerInformation(p) => serde_json::to_string(p),
1842 Self::DataTransfer(p) => serde_json::to_string(p),
1843 Self::DeleteCertificate(p) => serde_json::to_string(p),
1844 Self::GetBaseReport(p) => serde_json::to_string(p),
1845 Self::GetChargingProfiles(p) => serde_json::to_string(p),
1846 Self::GetCompositeSchedule(p) => serde_json::to_string(p),
1847 Self::GetDisplayMessages(p) => serde_json::to_string(p),
1848 Self::GetInstalledCertificateIds(p) => serde_json::to_string(p),
1849 Self::GetLocalListVersion(p) => serde_json::to_string(p),
1850 Self::GetLog(p) => serde_json::to_string(p),
1851 Self::GetMonitoringReport(p) => serde_json::to_string(p),
1852 Self::GetReport(p) => serde_json::to_string(p),
1853 Self::GetTransactionStatus(p) => serde_json::to_string(p),
1854 Self::GetVariables(p) => serde_json::to_string(p),
1855 Self::InstallCertificate(p) => serde_json::to_string(p),
1856 Self::PublishFirmware(p) => serde_json::to_string(p),
1857 Self::RequestStartTransaction(p) => serde_json::to_string(p),
1858 Self::RequestStopTransaction(p) => serde_json::to_string(p),
1859 Self::ReserveNow(p) => serde_json::to_string(p),
1860 Self::Reset(p) => serde_json::to_string(p),
1861 Self::SendLocalList(p) => serde_json::to_string(p),
1862 Self::SetChargingProfile(p) => serde_json::to_string(p),
1863 Self::SetDisplayMessage(p) => serde_json::to_string(p),
1864 Self::SetMonitoringBase(p) => serde_json::to_string(p),
1865 Self::SetMonitoringLevel(p) => serde_json::to_string(p),
1866 Self::SetNetworkProfile(p) => serde_json::to_string(p),
1867 Self::SetVariableMonitoring(p) => serde_json::to_string(p),
1868 Self::SetVariables(p) => serde_json::to_string(p),
1869 Self::TriggerMessage(p) => serde_json::to_string(p),
1870 Self::UnlockConnector(p) => serde_json::to_string(p),
1871 Self::UnpublishFirmware(p) => serde_json::to_string(p),
1872 Self::UpdateFirmware(p) => serde_json::to_string(p),
1873 }
1874 }
1875}
1876
1877impl Validate for CsmsRequest {
1878 fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
1879 match self {
1880 Self::CancelReservation(p) => p.validate_at(path, out),
1881 Self::CertificateSigned(p) => p.validate_at(path, out),
1882 Self::ChangeAvailability(p) => p.validate_at(path, out),
1883 Self::ClearCache(p) => p.validate_at(path, out),
1884 Self::ClearChargingProfile(p) => p.validate_at(path, out),
1885 Self::ClearDisplayMessage(p) => p.validate_at(path, out),
1886 Self::ClearVariableMonitoring(p) => p.validate_at(path, out),
1887 Self::CostUpdated(p) => p.validate_at(path, out),
1888 Self::CustomerInformation(p) => p.validate_at(path, out),
1889 Self::DataTransfer(p) => p.validate_at(path, out),
1890 Self::DeleteCertificate(p) => p.validate_at(path, out),
1891 Self::GetBaseReport(p) => p.validate_at(path, out),
1892 Self::GetChargingProfiles(p) => p.validate_at(path, out),
1893 Self::GetCompositeSchedule(p) => p.validate_at(path, out),
1894 Self::GetDisplayMessages(p) => p.validate_at(path, out),
1895 Self::GetInstalledCertificateIds(p) => p.validate_at(path, out),
1896 Self::GetLocalListVersion(p) => p.validate_at(path, out),
1897 Self::GetLog(p) => p.validate_at(path, out),
1898 Self::GetMonitoringReport(p) => p.validate_at(path, out),
1899 Self::GetReport(p) => p.validate_at(path, out),
1900 Self::GetTransactionStatus(p) => p.validate_at(path, out),
1901 Self::GetVariables(p) => p.validate_at(path, out),
1902 Self::InstallCertificate(p) => p.validate_at(path, out),
1903 Self::PublishFirmware(p) => p.validate_at(path, out),
1904 Self::RequestStartTransaction(p) => p.validate_at(path, out),
1905 Self::RequestStopTransaction(p) => p.validate_at(path, out),
1906 Self::ReserveNow(p) => p.validate_at(path, out),
1907 Self::Reset(p) => p.validate_at(path, out),
1908 Self::SendLocalList(p) => p.validate_at(path, out),
1909 Self::SetChargingProfile(p) => p.validate_at(path, out),
1910 Self::SetDisplayMessage(p) => p.validate_at(path, out),
1911 Self::SetMonitoringBase(p) => p.validate_at(path, out),
1912 Self::SetMonitoringLevel(p) => p.validate_at(path, out),
1913 Self::SetNetworkProfile(p) => p.validate_at(path, out),
1914 Self::SetVariableMonitoring(p) => p.validate_at(path, out),
1915 Self::SetVariables(p) => p.validate_at(path, out),
1916 Self::TriggerMessage(p) => p.validate_at(path, out),
1917 Self::UnlockConnector(p) => p.validate_at(path, out),
1918 Self::UnpublishFirmware(p) => p.validate_at(path, out),
1919 Self::UpdateFirmware(p) => p.validate_at(path, out),
1920 }
1921 }
1922}
1923
1924impl serde::Serialize for CsmsRequest {
1925 fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
1926 match self {
1927 Self::CancelReservation(p) => p.serialize(ser),
1928 Self::CertificateSigned(p) => p.serialize(ser),
1929 Self::ChangeAvailability(p) => p.serialize(ser),
1930 Self::ClearCache(p) => p.serialize(ser),
1931 Self::ClearChargingProfile(p) => p.serialize(ser),
1932 Self::ClearDisplayMessage(p) => p.serialize(ser),
1933 Self::ClearVariableMonitoring(p) => p.serialize(ser),
1934 Self::CostUpdated(p) => p.serialize(ser),
1935 Self::CustomerInformation(p) => p.serialize(ser),
1936 Self::DataTransfer(p) => p.serialize(ser),
1937 Self::DeleteCertificate(p) => p.serialize(ser),
1938 Self::GetBaseReport(p) => p.serialize(ser),
1939 Self::GetChargingProfiles(p) => p.serialize(ser),
1940 Self::GetCompositeSchedule(p) => p.serialize(ser),
1941 Self::GetDisplayMessages(p) => p.serialize(ser),
1942 Self::GetInstalledCertificateIds(p) => p.serialize(ser),
1943 Self::GetLocalListVersion(p) => p.serialize(ser),
1944 Self::GetLog(p) => p.serialize(ser),
1945 Self::GetMonitoringReport(p) => p.serialize(ser),
1946 Self::GetReport(p) => p.serialize(ser),
1947 Self::GetTransactionStatus(p) => p.serialize(ser),
1948 Self::GetVariables(p) => p.serialize(ser),
1949 Self::InstallCertificate(p) => p.serialize(ser),
1950 Self::PublishFirmware(p) => p.serialize(ser),
1951 Self::RequestStartTransaction(p) => p.serialize(ser),
1952 Self::RequestStopTransaction(p) => p.serialize(ser),
1953 Self::ReserveNow(p) => p.serialize(ser),
1954 Self::Reset(p) => p.serialize(ser),
1955 Self::SendLocalList(p) => p.serialize(ser),
1956 Self::SetChargingProfile(p) => p.serialize(ser),
1957 Self::SetDisplayMessage(p) => p.serialize(ser),
1958 Self::SetMonitoringBase(p) => p.serialize(ser),
1959 Self::SetMonitoringLevel(p) => p.serialize(ser),
1960 Self::SetNetworkProfile(p) => p.serialize(ser),
1961 Self::SetVariableMonitoring(p) => p.serialize(ser),
1962 Self::SetVariables(p) => p.serialize(ser),
1963 Self::TriggerMessage(p) => p.serialize(ser),
1964 Self::UnlockConnector(p) => p.serialize(ser),
1965 Self::UnpublishFirmware(p) => p.serialize(ser),
1966 Self::UpdateFirmware(p) => p.serialize(ser),
1967 }
1968 }
1969}
1970
1971#[derive(Clone, Debug, PartialEq)]
1973#[non_exhaustive]
1974#[allow(clippy::large_enum_variant)]
1975pub enum CsmsResponse {
1976 CancelReservation(CancelReservationResponse),
1978 CertificateSigned(CertificateSignedResponse),
1980 ChangeAvailability(ChangeAvailabilityResponse),
1982 ClearCache(ClearCacheResponse),
1984 ClearChargingProfile(ClearChargingProfileResponse),
1986 ClearDisplayMessage(ClearDisplayMessageResponse),
1988 ClearVariableMonitoring(ClearVariableMonitoringResponse),
1990 CostUpdated(CostUpdatedResponse),
1992 CustomerInformation(CustomerInformationResponse),
1994 DataTransfer(DataTransferResponse),
1996 DeleteCertificate(DeleteCertificateResponse),
1998 GetBaseReport(GetBaseReportResponse),
2000 GetChargingProfiles(GetChargingProfilesResponse),
2002 GetCompositeSchedule(GetCompositeScheduleResponse),
2004 GetDisplayMessages(GetDisplayMessagesResponse),
2006 GetInstalledCertificateIds(GetInstalledCertificateIdsResponse),
2008 GetLocalListVersion(GetLocalListVersionResponse),
2010 GetLog(GetLogResponse),
2012 GetMonitoringReport(GetMonitoringReportResponse),
2014 GetReport(GetReportResponse),
2016 GetTransactionStatus(GetTransactionStatusResponse),
2018 GetVariables(GetVariablesResponse),
2020 InstallCertificate(InstallCertificateResponse),
2022 PublishFirmware(PublishFirmwareResponse),
2024 RequestStartTransaction(RequestStartTransactionResponse),
2026 RequestStopTransaction(RequestStopTransactionResponse),
2028 ReserveNow(ReserveNowResponse),
2030 Reset(ResetResponse),
2032 SendLocalList(SendLocalListResponse),
2034 SetChargingProfile(SetChargingProfileResponse),
2036 SetDisplayMessage(SetDisplayMessageResponse),
2038 SetMonitoringBase(SetMonitoringBaseResponse),
2040 SetMonitoringLevel(SetMonitoringLevelResponse),
2042 SetNetworkProfile(SetNetworkProfileResponse),
2044 SetVariableMonitoring(SetVariableMonitoringResponse),
2046 SetVariables(SetVariablesResponse),
2048 TriggerMessage(TriggerMessageResponse),
2050 UnlockConnector(UnlockConnectorResponse),
2052 UnpublishFirmware(UnpublishFirmwareResponse),
2054 UpdateFirmware(UpdateFirmwareResponse),
2056}
2057
2058impl CsmsResponse {
2059 #[must_use]
2061 pub const fn action(&self) -> Action {
2062 match self {
2063 Self::CancelReservation(_) => Action::CancelReservation,
2064 Self::CertificateSigned(_) => Action::CertificateSigned,
2065 Self::ChangeAvailability(_) => Action::ChangeAvailability,
2066 Self::ClearCache(_) => Action::ClearCache,
2067 Self::ClearChargingProfile(_) => Action::ClearChargingProfile,
2068 Self::ClearDisplayMessage(_) => Action::ClearDisplayMessage,
2069 Self::ClearVariableMonitoring(_) => Action::ClearVariableMonitoring,
2070 Self::CostUpdated(_) => Action::CostUpdated,
2071 Self::CustomerInformation(_) => Action::CustomerInformation,
2072 Self::DataTransfer(_) => Action::DataTransfer,
2073 Self::DeleteCertificate(_) => Action::DeleteCertificate,
2074 Self::GetBaseReport(_) => Action::GetBaseReport,
2075 Self::GetChargingProfiles(_) => Action::GetChargingProfiles,
2076 Self::GetCompositeSchedule(_) => Action::GetCompositeSchedule,
2077 Self::GetDisplayMessages(_) => Action::GetDisplayMessages,
2078 Self::GetInstalledCertificateIds(_) => Action::GetInstalledCertificateIds,
2079 Self::GetLocalListVersion(_) => Action::GetLocalListVersion,
2080 Self::GetLog(_) => Action::GetLog,
2081 Self::GetMonitoringReport(_) => Action::GetMonitoringReport,
2082 Self::GetReport(_) => Action::GetReport,
2083 Self::GetTransactionStatus(_) => Action::GetTransactionStatus,
2084 Self::GetVariables(_) => Action::GetVariables,
2085 Self::InstallCertificate(_) => Action::InstallCertificate,
2086 Self::PublishFirmware(_) => Action::PublishFirmware,
2087 Self::RequestStartTransaction(_) => Action::RequestStartTransaction,
2088 Self::RequestStopTransaction(_) => Action::RequestStopTransaction,
2089 Self::ReserveNow(_) => Action::ReserveNow,
2090 Self::Reset(_) => Action::Reset,
2091 Self::SendLocalList(_) => Action::SendLocalList,
2092 Self::SetChargingProfile(_) => Action::SetChargingProfile,
2093 Self::SetDisplayMessage(_) => Action::SetDisplayMessage,
2094 Self::SetMonitoringBase(_) => Action::SetMonitoringBase,
2095 Self::SetMonitoringLevel(_) => Action::SetMonitoringLevel,
2096 Self::SetNetworkProfile(_) => Action::SetNetworkProfile,
2097 Self::SetVariableMonitoring(_) => Action::SetVariableMonitoring,
2098 Self::SetVariables(_) => Action::SetVariables,
2099 Self::TriggerMessage(_) => Action::TriggerMessage,
2100 Self::UnlockConnector(_) => Action::UnlockConnector,
2101 Self::UnpublishFirmware(_) => Action::UnpublishFirmware,
2102 Self::UpdateFirmware(_) => Action::UpdateFirmware,
2103 }
2104 }
2105
2106 pub fn decode(
2109 action: Action,
2110 payload: &RawValue,
2111 options: &DecodeOptions,
2112 ) -> Result<Self, DecodeError> {
2113 Ok(match action {
2114 Action::CancelReservation => Self::CancelReservation(crate::decode::decode_payload::<
2115 CancelReservationResponse,
2116 >(payload, options)?),
2117 Action::CertificateSigned => Self::CertificateSigned(crate::decode::decode_payload::<
2118 CertificateSignedResponse,
2119 >(payload, options)?),
2120 Action::ChangeAvailability => Self::ChangeAvailability(
2121 crate::decode::decode_payload::<ChangeAvailabilityResponse>(payload, options)?,
2122 ),
2123 Action::ClearCache => Self::ClearCache(crate::decode::decode_payload::<
2124 ClearCacheResponse,
2125 >(payload, options)?),
2126 Action::ClearChargingProfile => {
2127 Self::ClearChargingProfile(crate::decode::decode_payload::<
2128 ClearChargingProfileResponse,
2129 >(payload, options)?)
2130 }
2131 Action::ClearDisplayMessage => {
2132 Self::ClearDisplayMessage(crate::decode::decode_payload::<
2133 ClearDisplayMessageResponse,
2134 >(payload, options)?)
2135 }
2136 Action::ClearVariableMonitoring => {
2137 Self::ClearVariableMonitoring(crate::decode::decode_payload::<
2138 ClearVariableMonitoringResponse,
2139 >(payload, options)?)
2140 }
2141 Action::CostUpdated => Self::CostUpdated(crate::decode::decode_payload::<
2142 CostUpdatedResponse,
2143 >(payload, options)?),
2144 Action::CustomerInformation => {
2145 Self::CustomerInformation(crate::decode::decode_payload::<
2146 CustomerInformationResponse,
2147 >(payload, options)?)
2148 }
2149 Action::DataTransfer => Self::DataTransfer(crate::decode::decode_payload::<
2150 DataTransferResponse,
2151 >(payload, options)?),
2152 Action::DeleteCertificate => Self::DeleteCertificate(crate::decode::decode_payload::<
2153 DeleteCertificateResponse,
2154 >(payload, options)?),
2155 Action::GetBaseReport => Self::GetBaseReport(crate::decode::decode_payload::<
2156 GetBaseReportResponse,
2157 >(payload, options)?),
2158 Action::GetChargingProfiles => {
2159 Self::GetChargingProfiles(crate::decode::decode_payload::<
2160 GetChargingProfilesResponse,
2161 >(payload, options)?)
2162 }
2163 Action::GetCompositeSchedule => {
2164 Self::GetCompositeSchedule(crate::decode::decode_payload::<
2165 GetCompositeScheduleResponse,
2166 >(payload, options)?)
2167 }
2168 Action::GetDisplayMessages => Self::GetDisplayMessages(
2169 crate::decode::decode_payload::<GetDisplayMessagesResponse>(payload, options)?,
2170 ),
2171 Action::GetInstalledCertificateIds => {
2172 Self::GetInstalledCertificateIds(crate::decode::decode_payload::<
2173 GetInstalledCertificateIdsResponse,
2174 >(payload, options)?)
2175 }
2176 Action::GetLocalListVersion => {
2177 Self::GetLocalListVersion(crate::decode::decode_payload::<
2178 GetLocalListVersionResponse,
2179 >(payload, options)?)
2180 }
2181 Action::GetLog => Self::GetLog(crate::decode::decode_payload::<GetLogResponse>(
2182 payload, options,
2183 )?),
2184 Action::GetMonitoringReport => {
2185 Self::GetMonitoringReport(crate::decode::decode_payload::<
2186 GetMonitoringReportResponse,
2187 >(payload, options)?)
2188 }
2189 Action::GetReport => Self::GetReport(
2190 crate::decode::decode_payload::<GetReportResponse>(payload, options)?,
2191 ),
2192 Action::GetTransactionStatus => {
2193 Self::GetTransactionStatus(crate::decode::decode_payload::<
2194 GetTransactionStatusResponse,
2195 >(payload, options)?)
2196 }
2197 Action::GetVariables => Self::GetVariables(crate::decode::decode_payload::<
2198 GetVariablesResponse,
2199 >(payload, options)?),
2200 Action::InstallCertificate => Self::InstallCertificate(
2201 crate::decode::decode_payload::<InstallCertificateResponse>(payload, options)?,
2202 ),
2203 Action::PublishFirmware => Self::PublishFirmware(crate::decode::decode_payload::<
2204 PublishFirmwareResponse,
2205 >(payload, options)?),
2206 Action::RequestStartTransaction => {
2207 Self::RequestStartTransaction(crate::decode::decode_payload::<
2208 RequestStartTransactionResponse,
2209 >(payload, options)?)
2210 }
2211 Action::RequestStopTransaction => {
2212 Self::RequestStopTransaction(crate::decode::decode_payload::<
2213 RequestStopTransactionResponse,
2214 >(payload, options)?)
2215 }
2216 Action::ReserveNow => Self::ReserveNow(crate::decode::decode_payload::<
2217 ReserveNowResponse,
2218 >(payload, options)?),
2219 Action::Reset => Self::Reset(crate::decode::decode_payload::<ResetResponse>(
2220 payload, options,
2221 )?),
2222 Action::SendLocalList => Self::SendLocalList(crate::decode::decode_payload::<
2223 SendLocalListResponse,
2224 >(payload, options)?),
2225 Action::SetChargingProfile => Self::SetChargingProfile(
2226 crate::decode::decode_payload::<SetChargingProfileResponse>(payload, options)?,
2227 ),
2228 Action::SetDisplayMessage => Self::SetDisplayMessage(crate::decode::decode_payload::<
2229 SetDisplayMessageResponse,
2230 >(payload, options)?),
2231 Action::SetMonitoringBase => Self::SetMonitoringBase(crate::decode::decode_payload::<
2232 SetMonitoringBaseResponse,
2233 >(payload, options)?),
2234 Action::SetMonitoringLevel => Self::SetMonitoringLevel(
2235 crate::decode::decode_payload::<SetMonitoringLevelResponse>(payload, options)?,
2236 ),
2237 Action::SetNetworkProfile => Self::SetNetworkProfile(crate::decode::decode_payload::<
2238 SetNetworkProfileResponse,
2239 >(payload, options)?),
2240 Action::SetVariableMonitoring => {
2241 Self::SetVariableMonitoring(crate::decode::decode_payload::<
2242 SetVariableMonitoringResponse,
2243 >(payload, options)?)
2244 }
2245 Action::SetVariables => Self::SetVariables(crate::decode::decode_payload::<
2246 SetVariablesResponse,
2247 >(payload, options)?),
2248 Action::TriggerMessage => Self::TriggerMessage(crate::decode::decode_payload::<
2249 TriggerMessageResponse,
2250 >(payload, options)?),
2251 Action::UnlockConnector => Self::UnlockConnector(crate::decode::decode_payload::<
2252 UnlockConnectorResponse,
2253 >(payload, options)?),
2254 Action::UnpublishFirmware => Self::UnpublishFirmware(crate::decode::decode_payload::<
2255 UnpublishFirmwareResponse,
2256 >(payload, options)?),
2257 Action::UpdateFirmware => Self::UpdateFirmware(crate::decode::decode_payload::<
2258 UpdateFirmwareResponse,
2259 >(payload, options)?),
2260 other => return Err(DecodeError::unsupported_action(other.as_str())),
2261 })
2262 }
2263
2264 pub fn to_json(&self) -> Result<alloc::string::String, serde_json::Error> {
2266 match self {
2267 Self::CancelReservation(p) => serde_json::to_string(p),
2268 Self::CertificateSigned(p) => serde_json::to_string(p),
2269 Self::ChangeAvailability(p) => serde_json::to_string(p),
2270 Self::ClearCache(p) => serde_json::to_string(p),
2271 Self::ClearChargingProfile(p) => serde_json::to_string(p),
2272 Self::ClearDisplayMessage(p) => serde_json::to_string(p),
2273 Self::ClearVariableMonitoring(p) => serde_json::to_string(p),
2274 Self::CostUpdated(p) => serde_json::to_string(p),
2275 Self::CustomerInformation(p) => serde_json::to_string(p),
2276 Self::DataTransfer(p) => serde_json::to_string(p),
2277 Self::DeleteCertificate(p) => serde_json::to_string(p),
2278 Self::GetBaseReport(p) => serde_json::to_string(p),
2279 Self::GetChargingProfiles(p) => serde_json::to_string(p),
2280 Self::GetCompositeSchedule(p) => serde_json::to_string(p),
2281 Self::GetDisplayMessages(p) => serde_json::to_string(p),
2282 Self::GetInstalledCertificateIds(p) => serde_json::to_string(p),
2283 Self::GetLocalListVersion(p) => serde_json::to_string(p),
2284 Self::GetLog(p) => serde_json::to_string(p),
2285 Self::GetMonitoringReport(p) => serde_json::to_string(p),
2286 Self::GetReport(p) => serde_json::to_string(p),
2287 Self::GetTransactionStatus(p) => serde_json::to_string(p),
2288 Self::GetVariables(p) => serde_json::to_string(p),
2289 Self::InstallCertificate(p) => serde_json::to_string(p),
2290 Self::PublishFirmware(p) => serde_json::to_string(p),
2291 Self::RequestStartTransaction(p) => serde_json::to_string(p),
2292 Self::RequestStopTransaction(p) => serde_json::to_string(p),
2293 Self::ReserveNow(p) => serde_json::to_string(p),
2294 Self::Reset(p) => serde_json::to_string(p),
2295 Self::SendLocalList(p) => serde_json::to_string(p),
2296 Self::SetChargingProfile(p) => serde_json::to_string(p),
2297 Self::SetDisplayMessage(p) => serde_json::to_string(p),
2298 Self::SetMonitoringBase(p) => serde_json::to_string(p),
2299 Self::SetMonitoringLevel(p) => serde_json::to_string(p),
2300 Self::SetNetworkProfile(p) => serde_json::to_string(p),
2301 Self::SetVariableMonitoring(p) => serde_json::to_string(p),
2302 Self::SetVariables(p) => serde_json::to_string(p),
2303 Self::TriggerMessage(p) => serde_json::to_string(p),
2304 Self::UnlockConnector(p) => serde_json::to_string(p),
2305 Self::UnpublishFirmware(p) => serde_json::to_string(p),
2306 Self::UpdateFirmware(p) => serde_json::to_string(p),
2307 }
2308 }
2309}
2310
2311impl Validate for CsmsResponse {
2312 fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
2313 match self {
2314 Self::CancelReservation(p) => p.validate_at(path, out),
2315 Self::CertificateSigned(p) => p.validate_at(path, out),
2316 Self::ChangeAvailability(p) => p.validate_at(path, out),
2317 Self::ClearCache(p) => p.validate_at(path, out),
2318 Self::ClearChargingProfile(p) => p.validate_at(path, out),
2319 Self::ClearDisplayMessage(p) => p.validate_at(path, out),
2320 Self::ClearVariableMonitoring(p) => p.validate_at(path, out),
2321 Self::CostUpdated(p) => p.validate_at(path, out),
2322 Self::CustomerInformation(p) => p.validate_at(path, out),
2323 Self::DataTransfer(p) => p.validate_at(path, out),
2324 Self::DeleteCertificate(p) => p.validate_at(path, out),
2325 Self::GetBaseReport(p) => p.validate_at(path, out),
2326 Self::GetChargingProfiles(p) => p.validate_at(path, out),
2327 Self::GetCompositeSchedule(p) => p.validate_at(path, out),
2328 Self::GetDisplayMessages(p) => p.validate_at(path, out),
2329 Self::GetInstalledCertificateIds(p) => p.validate_at(path, out),
2330 Self::GetLocalListVersion(p) => p.validate_at(path, out),
2331 Self::GetLog(p) => p.validate_at(path, out),
2332 Self::GetMonitoringReport(p) => p.validate_at(path, out),
2333 Self::GetReport(p) => p.validate_at(path, out),
2334 Self::GetTransactionStatus(p) => p.validate_at(path, out),
2335 Self::GetVariables(p) => p.validate_at(path, out),
2336 Self::InstallCertificate(p) => p.validate_at(path, out),
2337 Self::PublishFirmware(p) => p.validate_at(path, out),
2338 Self::RequestStartTransaction(p) => p.validate_at(path, out),
2339 Self::RequestStopTransaction(p) => p.validate_at(path, out),
2340 Self::ReserveNow(p) => p.validate_at(path, out),
2341 Self::Reset(p) => p.validate_at(path, out),
2342 Self::SendLocalList(p) => p.validate_at(path, out),
2343 Self::SetChargingProfile(p) => p.validate_at(path, out),
2344 Self::SetDisplayMessage(p) => p.validate_at(path, out),
2345 Self::SetMonitoringBase(p) => p.validate_at(path, out),
2346 Self::SetMonitoringLevel(p) => p.validate_at(path, out),
2347 Self::SetNetworkProfile(p) => p.validate_at(path, out),
2348 Self::SetVariableMonitoring(p) => p.validate_at(path, out),
2349 Self::SetVariables(p) => p.validate_at(path, out),
2350 Self::TriggerMessage(p) => p.validate_at(path, out),
2351 Self::UnlockConnector(p) => p.validate_at(path, out),
2352 Self::UnpublishFirmware(p) => p.validate_at(path, out),
2353 Self::UpdateFirmware(p) => p.validate_at(path, out),
2354 }
2355 }
2356}
2357
2358impl serde::Serialize for CsmsResponse {
2359 fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
2360 match self {
2361 Self::CancelReservation(p) => p.serialize(ser),
2362 Self::CertificateSigned(p) => p.serialize(ser),
2363 Self::ChangeAvailability(p) => p.serialize(ser),
2364 Self::ClearCache(p) => p.serialize(ser),
2365 Self::ClearChargingProfile(p) => p.serialize(ser),
2366 Self::ClearDisplayMessage(p) => p.serialize(ser),
2367 Self::ClearVariableMonitoring(p) => p.serialize(ser),
2368 Self::CostUpdated(p) => p.serialize(ser),
2369 Self::CustomerInformation(p) => p.serialize(ser),
2370 Self::DataTransfer(p) => p.serialize(ser),
2371 Self::DeleteCertificate(p) => p.serialize(ser),
2372 Self::GetBaseReport(p) => p.serialize(ser),
2373 Self::GetChargingProfiles(p) => p.serialize(ser),
2374 Self::GetCompositeSchedule(p) => p.serialize(ser),
2375 Self::GetDisplayMessages(p) => p.serialize(ser),
2376 Self::GetInstalledCertificateIds(p) => p.serialize(ser),
2377 Self::GetLocalListVersion(p) => p.serialize(ser),
2378 Self::GetLog(p) => p.serialize(ser),
2379 Self::GetMonitoringReport(p) => p.serialize(ser),
2380 Self::GetReport(p) => p.serialize(ser),
2381 Self::GetTransactionStatus(p) => p.serialize(ser),
2382 Self::GetVariables(p) => p.serialize(ser),
2383 Self::InstallCertificate(p) => p.serialize(ser),
2384 Self::PublishFirmware(p) => p.serialize(ser),
2385 Self::RequestStartTransaction(p) => p.serialize(ser),
2386 Self::RequestStopTransaction(p) => p.serialize(ser),
2387 Self::ReserveNow(p) => p.serialize(ser),
2388 Self::Reset(p) => p.serialize(ser),
2389 Self::SendLocalList(p) => p.serialize(ser),
2390 Self::SetChargingProfile(p) => p.serialize(ser),
2391 Self::SetDisplayMessage(p) => p.serialize(ser),
2392 Self::SetMonitoringBase(p) => p.serialize(ser),
2393 Self::SetMonitoringLevel(p) => p.serialize(ser),
2394 Self::SetNetworkProfile(p) => p.serialize(ser),
2395 Self::SetVariableMonitoring(p) => p.serialize(ser),
2396 Self::SetVariables(p) => p.serialize(ser),
2397 Self::TriggerMessage(p) => p.serialize(ser),
2398 Self::UnlockConnector(p) => p.serialize(ser),
2399 Self::UnpublishFirmware(p) => p.serialize(ser),
2400 Self::UpdateFirmware(p) => p.serialize(ser),
2401 }
2402 }
2403}