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 ChangeConfiguration,
43 ClearCache,
45 ClearChargingProfile,
47 DataTransfer,
49 DeleteCertificate,
51 DiagnosticsStatusNotification,
53 ExtendedTriggerMessage,
55 FirmwareStatusNotification,
57 GetCompositeSchedule,
59 GetConfiguration,
61 GetDiagnostics,
63 GetInstalledCertificateIds,
65 GetLocalListVersion,
67 GetLog,
69 Heartbeat,
71 InstallCertificate,
73 LogStatusNotification,
75 MeterValues,
77 RemoteStartTransaction,
79 RemoteStopTransaction,
81 ReserveNow,
83 Reset,
85 SecurityEventNotification,
87 SendLocalList,
89 SetChargingProfile,
91 SignCertificate,
93 SignedFirmwareStatusNotification,
95 SignedUpdateFirmware,
97 StartTransaction,
99 StatusNotification,
101 StopTransaction,
103 TriggerMessage,
105 UnlockConnector,
107 UpdateFirmware,
109}
110
111impl Action {
112 pub const ALL: &'static [Action] = &[
114 Action::Authorize,
115 Action::BootNotification,
116 Action::CancelReservation,
117 Action::CertificateSigned,
118 Action::ChangeAvailability,
119 Action::ChangeConfiguration,
120 Action::ClearCache,
121 Action::ClearChargingProfile,
122 Action::DataTransfer,
123 Action::DeleteCertificate,
124 Action::DiagnosticsStatusNotification,
125 Action::ExtendedTriggerMessage,
126 Action::FirmwareStatusNotification,
127 Action::GetCompositeSchedule,
128 Action::GetConfiguration,
129 Action::GetDiagnostics,
130 Action::GetInstalledCertificateIds,
131 Action::GetLocalListVersion,
132 Action::GetLog,
133 Action::Heartbeat,
134 Action::InstallCertificate,
135 Action::LogStatusNotification,
136 Action::MeterValues,
137 Action::RemoteStartTransaction,
138 Action::RemoteStopTransaction,
139 Action::ReserveNow,
140 Action::Reset,
141 Action::SecurityEventNotification,
142 Action::SendLocalList,
143 Action::SetChargingProfile,
144 Action::SignCertificate,
145 Action::SignedFirmwareStatusNotification,
146 Action::SignedUpdateFirmware,
147 Action::StartTransaction,
148 Action::StatusNotification,
149 Action::StopTransaction,
150 Action::TriggerMessage,
151 Action::UnlockConnector,
152 Action::UpdateFirmware,
153 ];
154
155 #[must_use]
157 pub const fn as_str(self) -> &'static str {
158 match self {
159 Action::Authorize => "Authorize",
160 Action::BootNotification => "BootNotification",
161 Action::CancelReservation => "CancelReservation",
162 Action::CertificateSigned => "CertificateSigned",
163 Action::ChangeAvailability => "ChangeAvailability",
164 Action::ChangeConfiguration => "ChangeConfiguration",
165 Action::ClearCache => "ClearCache",
166 Action::ClearChargingProfile => "ClearChargingProfile",
167 Action::DataTransfer => "DataTransfer",
168 Action::DeleteCertificate => "DeleteCertificate",
169 Action::DiagnosticsStatusNotification => "DiagnosticsStatusNotification",
170 Action::ExtendedTriggerMessage => "ExtendedTriggerMessage",
171 Action::FirmwareStatusNotification => "FirmwareStatusNotification",
172 Action::GetCompositeSchedule => "GetCompositeSchedule",
173 Action::GetConfiguration => "GetConfiguration",
174 Action::GetDiagnostics => "GetDiagnostics",
175 Action::GetInstalledCertificateIds => "GetInstalledCertificateIds",
176 Action::GetLocalListVersion => "GetLocalListVersion",
177 Action::GetLog => "GetLog",
178 Action::Heartbeat => "Heartbeat",
179 Action::InstallCertificate => "InstallCertificate",
180 Action::LogStatusNotification => "LogStatusNotification",
181 Action::MeterValues => "MeterValues",
182 Action::RemoteStartTransaction => "RemoteStartTransaction",
183 Action::RemoteStopTransaction => "RemoteStopTransaction",
184 Action::ReserveNow => "ReserveNow",
185 Action::Reset => "Reset",
186 Action::SecurityEventNotification => "SecurityEventNotification",
187 Action::SendLocalList => "SendLocalList",
188 Action::SetChargingProfile => "SetChargingProfile",
189 Action::SignCertificate => "SignCertificate",
190 Action::SignedFirmwareStatusNotification => "SignedFirmwareStatusNotification",
191 Action::SignedUpdateFirmware => "SignedUpdateFirmware",
192 Action::StartTransaction => "StartTransaction",
193 Action::StatusNotification => "StatusNotification",
194 Action::StopTransaction => "StopTransaction",
195 Action::TriggerMessage => "TriggerMessage",
196 Action::UnlockConnector => "UnlockConnector",
197 Action::UpdateFirmware => "UpdateFirmware",
198 }
199 }
200
201 #[must_use]
203 pub fn from_wire(name: &str) -> Option<Self> {
204 Some(match name {
205 "Authorize" => Action::Authorize,
206 "BootNotification" => Action::BootNotification,
207 "CancelReservation" => Action::CancelReservation,
208 "CertificateSigned" => Action::CertificateSigned,
209 "ChangeAvailability" => Action::ChangeAvailability,
210 "ChangeConfiguration" => Action::ChangeConfiguration,
211 "ClearCache" => Action::ClearCache,
212 "ClearChargingProfile" => Action::ClearChargingProfile,
213 "DataTransfer" => Action::DataTransfer,
214 "DeleteCertificate" => Action::DeleteCertificate,
215 "DiagnosticsStatusNotification" => Action::DiagnosticsStatusNotification,
216 "ExtendedTriggerMessage" => Action::ExtendedTriggerMessage,
217 "FirmwareStatusNotification" => Action::FirmwareStatusNotification,
218 "GetCompositeSchedule" => Action::GetCompositeSchedule,
219 "GetConfiguration" => Action::GetConfiguration,
220 "GetDiagnostics" => Action::GetDiagnostics,
221 "GetInstalledCertificateIds" => Action::GetInstalledCertificateIds,
222 "GetLocalListVersion" => Action::GetLocalListVersion,
223 "GetLog" => Action::GetLog,
224 "Heartbeat" => Action::Heartbeat,
225 "InstallCertificate" => Action::InstallCertificate,
226 "LogStatusNotification" => Action::LogStatusNotification,
227 "MeterValues" => Action::MeterValues,
228 "RemoteStartTransaction" => Action::RemoteStartTransaction,
229 "RemoteStopTransaction" => Action::RemoteStopTransaction,
230 "ReserveNow" => Action::ReserveNow,
231 "Reset" => Action::Reset,
232 "SecurityEventNotification" => Action::SecurityEventNotification,
233 "SendLocalList" => Action::SendLocalList,
234 "SetChargingProfile" => Action::SetChargingProfile,
235 "SignCertificate" => Action::SignCertificate,
236 "SignedFirmwareStatusNotification" => Action::SignedFirmwareStatusNotification,
237 "SignedUpdateFirmware" => Action::SignedUpdateFirmware,
238 "StartTransaction" => Action::StartTransaction,
239 "StatusNotification" => Action::StatusNotification,
240 "StopTransaction" => Action::StopTransaction,
241 "TriggerMessage" => Action::TriggerMessage,
242 "UnlockConnector" => Action::UnlockConnector,
243 "UpdateFirmware" => Action::UpdateFirmware,
244 _ => return None,
245 })
246 }
247
248 #[must_use]
250 pub const fn kind(self) -> MessageKind {
251 MessageKind::Call
252 }
253
254 #[must_use]
256 pub const fn origin(self) -> Origin {
257 match self {
258 Action::Authorize => Origin::ChargingStation,
259 Action::BootNotification => Origin::ChargingStation,
260 Action::CancelReservation => Origin::Csms,
261 Action::CertificateSigned => Origin::Csms,
262 Action::ChangeAvailability => Origin::Csms,
263 Action::ChangeConfiguration => Origin::Csms,
264 Action::ClearCache => Origin::Csms,
265 Action::ClearChargingProfile => Origin::Csms,
266 Action::DataTransfer => Origin::Both,
267 Action::DeleteCertificate => Origin::Csms,
268 Action::DiagnosticsStatusNotification => Origin::ChargingStation,
269 Action::ExtendedTriggerMessage => Origin::Csms,
270 Action::FirmwareStatusNotification => Origin::ChargingStation,
271 Action::GetCompositeSchedule => Origin::Csms,
272 Action::GetConfiguration => Origin::Csms,
273 Action::GetDiagnostics => Origin::Csms,
274 Action::GetInstalledCertificateIds => Origin::Csms,
275 Action::GetLocalListVersion => Origin::Csms,
276 Action::GetLog => Origin::Csms,
277 Action::Heartbeat => Origin::ChargingStation,
278 Action::InstallCertificate => Origin::Csms,
279 Action::LogStatusNotification => Origin::ChargingStation,
280 Action::MeterValues => Origin::ChargingStation,
281 Action::RemoteStartTransaction => Origin::Csms,
282 Action::RemoteStopTransaction => Origin::Csms,
283 Action::ReserveNow => Origin::Csms,
284 Action::Reset => Origin::Csms,
285 Action::SecurityEventNotification => Origin::ChargingStation,
286 Action::SendLocalList => Origin::Csms,
287 Action::SetChargingProfile => Origin::Csms,
288 Action::SignCertificate => Origin::ChargingStation,
289 Action::SignedFirmwareStatusNotification => Origin::ChargingStation,
290 Action::SignedUpdateFirmware => Origin::Csms,
291 Action::StartTransaction => Origin::ChargingStation,
292 Action::StatusNotification => Origin::ChargingStation,
293 Action::StopTransaction => Origin::ChargingStation,
294 Action::TriggerMessage => Origin::Csms,
295 Action::UnlockConnector => Origin::Csms,
296 Action::UpdateFirmware => Origin::Csms,
297 }
298 }
299
300 #[must_use]
302 pub const fn block(self) -> &'static str {
303 match self {
304 Action::Authorize => "Core",
305 Action::BootNotification => "Core",
306 Action::CancelReservation => "Reservation",
307 Action::CertificateSigned => "Security",
308 Action::ChangeAvailability => "Core",
309 Action::ChangeConfiguration => "Core",
310 Action::ClearCache => "Core",
311 Action::ClearChargingProfile => "SmartCharging",
312 Action::DataTransfer => "Core",
313 Action::DeleteCertificate => "Security",
314 Action::DiagnosticsStatusNotification => "FirmwareManagement",
315 Action::ExtendedTriggerMessage => "Security",
316 Action::FirmwareStatusNotification => "FirmwareManagement",
317 Action::GetCompositeSchedule => "SmartCharging",
318 Action::GetConfiguration => "Core",
319 Action::GetDiagnostics => "FirmwareManagement",
320 Action::GetInstalledCertificateIds => "Security",
321 Action::GetLocalListVersion => "LocalAuthListManagement",
322 Action::GetLog => "Security",
323 Action::Heartbeat => "Core",
324 Action::InstallCertificate => "Security",
325 Action::LogStatusNotification => "Security",
326 Action::MeterValues => "Core",
327 Action::RemoteStartTransaction => "Core",
328 Action::RemoteStopTransaction => "Core",
329 Action::ReserveNow => "Reservation",
330 Action::Reset => "Core",
331 Action::SecurityEventNotification => "Security",
332 Action::SendLocalList => "LocalAuthListManagement",
333 Action::SetChargingProfile => "SmartCharging",
334 Action::SignCertificate => "Security",
335 Action::SignedFirmwareStatusNotification => "Security",
336 Action::SignedUpdateFirmware => "Security",
337 Action::StartTransaction => "Core",
338 Action::StatusNotification => "Core",
339 Action::StopTransaction => "Core",
340 Action::TriggerMessage => "RemoteTrigger",
341 Action::UnlockConnector => "Core",
342 Action::UpdateFirmware => "FirmwareManagement",
343 }
344 }
345}
346
347impl crate::message::ActionName for Action {
348 fn all() -> &'static [Self] {
349 Self::ALL
350 }
351 fn as_str(&self) -> &'static str {
352 Action::as_str(*self)
353 }
354 fn from_wire(name: &str) -> Option<Self> {
355 Action::from_wire(name)
356 }
357 fn kind(&self) -> MessageKind {
358 Action::kind(*self)
359 }
360 fn origin(&self) -> Origin {
361 Action::origin(*self)
362 }
363 fn block(&self) -> &'static str {
364 Action::block(*self)
365 }
366}
367
368impl core::fmt::Display for Action {
369 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
370 f.write_str(self.as_str())
371 }
372}
373
374impl core::str::FromStr for Action {
375 type Err = crate::message::UnknownAction;
376 fn from_str(s: &str) -> Result<Self, Self::Err> {
377 Self::from_wire(s).ok_or(crate::message::UnknownAction)
378 }
379}
380
381impl Serialize for Action {
382 fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
383 ser.serialize_str(self.as_str())
384 }
385}
386
387impl<'de> Deserialize<'de> for Action {
388 fn deserialize<D: serde::Deserializer<'de>>(de: D) -> Result<Self, D::Error> {
389 let s = <&str as Deserialize>::deserialize(de)?;
390 Self::from_wire(s).ok_or_else(|| serde::de::Error::custom("unknown OCPP action"))
391 }
392}
393
394impl Action {
395 #[must_use]
399 pub const fn has_response(self) -> bool {
400 matches!(self.kind(), MessageKind::Call)
401 }
402}
403
404pub fn transcode_request(
410 action: Action,
411 payload: &RawValue,
412 options: &DecodeOptions,
413) -> Result<alloc::boxed::Box<RawValue>, DecodeError> {
414 match action {
415 Action::Authorize => crate::decode::transcode::<AuthorizeRequest>(payload, options),
416 Action::BootNotification => {
417 crate::decode::transcode::<BootNotificationRequest>(payload, options)
418 }
419 Action::CancelReservation => {
420 crate::decode::transcode::<CancelReservationRequest>(payload, options)
421 }
422 Action::CertificateSigned => {
423 crate::decode::transcode::<CertificateSignedRequest>(payload, options)
424 }
425 Action::ChangeAvailability => {
426 crate::decode::transcode::<ChangeAvailabilityRequest>(payload, options)
427 }
428 Action::ChangeConfiguration => {
429 crate::decode::transcode::<ChangeConfigurationRequest>(payload, options)
430 }
431 Action::ClearCache => crate::decode::transcode::<ClearCacheRequest>(payload, options),
432 Action::ClearChargingProfile => {
433 crate::decode::transcode::<ClearChargingProfileRequest>(payload, options)
434 }
435 Action::DataTransfer => crate::decode::transcode::<DataTransferRequest>(payload, options),
436 Action::DeleteCertificate => {
437 crate::decode::transcode::<DeleteCertificateRequest>(payload, options)
438 }
439 Action::DiagnosticsStatusNotification => {
440 crate::decode::transcode::<DiagnosticsStatusNotificationRequest>(payload, options)
441 }
442 Action::ExtendedTriggerMessage => {
443 crate::decode::transcode::<ExtendedTriggerMessageRequest>(payload, options)
444 }
445 Action::FirmwareStatusNotification => {
446 crate::decode::transcode::<FirmwareStatusNotificationRequest>(payload, options)
447 }
448 Action::GetCompositeSchedule => {
449 crate::decode::transcode::<GetCompositeScheduleRequest>(payload, options)
450 }
451 Action::GetConfiguration => {
452 crate::decode::transcode::<GetConfigurationRequest>(payload, options)
453 }
454 Action::GetDiagnostics => {
455 crate::decode::transcode::<GetDiagnosticsRequest>(payload, options)
456 }
457 Action::GetInstalledCertificateIds => {
458 crate::decode::transcode::<GetInstalledCertificateIdsRequest>(payload, options)
459 }
460 Action::GetLocalListVersion => {
461 crate::decode::transcode::<GetLocalListVersionRequest>(payload, options)
462 }
463 Action::GetLog => crate::decode::transcode::<GetLogRequest>(payload, options),
464 Action::Heartbeat => crate::decode::transcode::<HeartbeatRequest>(payload, options),
465 Action::InstallCertificate => {
466 crate::decode::transcode::<InstallCertificateRequest>(payload, options)
467 }
468 Action::LogStatusNotification => {
469 crate::decode::transcode::<LogStatusNotificationRequest>(payload, options)
470 }
471 Action::MeterValues => crate::decode::transcode::<MeterValuesRequest>(payload, options),
472 Action::RemoteStartTransaction => {
473 crate::decode::transcode::<RemoteStartTransactionRequest>(payload, options)
474 }
475 Action::RemoteStopTransaction => {
476 crate::decode::transcode::<RemoteStopTransactionRequest>(payload, options)
477 }
478 Action::ReserveNow => crate::decode::transcode::<ReserveNowRequest>(payload, options),
479 Action::Reset => crate::decode::transcode::<ResetRequest>(payload, options),
480 Action::SecurityEventNotification => {
481 crate::decode::transcode::<SecurityEventNotificationRequest>(payload, options)
482 }
483 Action::SendLocalList => crate::decode::transcode::<SendLocalListRequest>(payload, options),
484 Action::SetChargingProfile => {
485 crate::decode::transcode::<SetChargingProfileRequest>(payload, options)
486 }
487 Action::SignCertificate => {
488 crate::decode::transcode::<SignCertificateRequest>(payload, options)
489 }
490 Action::SignedFirmwareStatusNotification => {
491 crate::decode::transcode::<SignedFirmwareStatusNotificationRequest>(payload, options)
492 }
493 Action::SignedUpdateFirmware => {
494 crate::decode::transcode::<SignedUpdateFirmwareRequest>(payload, options)
495 }
496 Action::StartTransaction => {
497 crate::decode::transcode::<StartTransactionRequest>(payload, options)
498 }
499 Action::StatusNotification => {
500 crate::decode::transcode::<StatusNotificationRequest>(payload, options)
501 }
502 Action::StopTransaction => {
503 crate::decode::transcode::<StopTransactionRequest>(payload, options)
504 }
505 Action::TriggerMessage => {
506 crate::decode::transcode::<TriggerMessageRequest>(payload, options)
507 }
508 Action::UnlockConnector => {
509 crate::decode::transcode::<UnlockConnectorRequest>(payload, options)
510 }
511 Action::UpdateFirmware => {
512 crate::decode::transcode::<UpdateFirmwareRequest>(payload, options)
513 }
514 }
515}
516
517pub fn transcode_response(
521 action: Action,
522 payload: &RawValue,
523 options: &DecodeOptions,
524) -> Result<alloc::boxed::Box<RawValue>, DecodeError> {
525 match action {
526 Action::Authorize => crate::decode::transcode::<AuthorizeResponse>(payload, options),
527 Action::BootNotification => {
528 crate::decode::transcode::<BootNotificationResponse>(payload, options)
529 }
530 Action::CancelReservation => {
531 crate::decode::transcode::<CancelReservationResponse>(payload, options)
532 }
533 Action::CertificateSigned => {
534 crate::decode::transcode::<CertificateSignedResponse>(payload, options)
535 }
536 Action::ChangeAvailability => {
537 crate::decode::transcode::<ChangeAvailabilityResponse>(payload, options)
538 }
539 Action::ChangeConfiguration => {
540 crate::decode::transcode::<ChangeConfigurationResponse>(payload, options)
541 }
542 Action::ClearCache => crate::decode::transcode::<ClearCacheResponse>(payload, options),
543 Action::ClearChargingProfile => {
544 crate::decode::transcode::<ClearChargingProfileResponse>(payload, options)
545 }
546 Action::DataTransfer => crate::decode::transcode::<DataTransferResponse>(payload, options),
547 Action::DeleteCertificate => {
548 crate::decode::transcode::<DeleteCertificateResponse>(payload, options)
549 }
550 Action::DiagnosticsStatusNotification => {
551 crate::decode::transcode::<DiagnosticsStatusNotificationResponse>(payload, options)
552 }
553 Action::ExtendedTriggerMessage => {
554 crate::decode::transcode::<ExtendedTriggerMessageResponse>(payload, options)
555 }
556 Action::FirmwareStatusNotification => {
557 crate::decode::transcode::<FirmwareStatusNotificationResponse>(payload, options)
558 }
559 Action::GetCompositeSchedule => {
560 crate::decode::transcode::<GetCompositeScheduleResponse>(payload, options)
561 }
562 Action::GetConfiguration => {
563 crate::decode::transcode::<GetConfigurationResponse>(payload, options)
564 }
565 Action::GetDiagnostics => {
566 crate::decode::transcode::<GetDiagnosticsResponse>(payload, options)
567 }
568 Action::GetInstalledCertificateIds => {
569 crate::decode::transcode::<GetInstalledCertificateIdsResponse>(payload, options)
570 }
571 Action::GetLocalListVersion => {
572 crate::decode::transcode::<GetLocalListVersionResponse>(payload, options)
573 }
574 Action::GetLog => crate::decode::transcode::<GetLogResponse>(payload, options),
575 Action::Heartbeat => crate::decode::transcode::<HeartbeatResponse>(payload, options),
576 Action::InstallCertificate => {
577 crate::decode::transcode::<InstallCertificateResponse>(payload, options)
578 }
579 Action::LogStatusNotification => {
580 crate::decode::transcode::<LogStatusNotificationResponse>(payload, options)
581 }
582 Action::MeterValues => crate::decode::transcode::<MeterValuesResponse>(payload, options),
583 Action::RemoteStartTransaction => {
584 crate::decode::transcode::<RemoteStartTransactionResponse>(payload, options)
585 }
586 Action::RemoteStopTransaction => {
587 crate::decode::transcode::<RemoteStopTransactionResponse>(payload, options)
588 }
589 Action::ReserveNow => crate::decode::transcode::<ReserveNowResponse>(payload, options),
590 Action::Reset => crate::decode::transcode::<ResetResponse>(payload, options),
591 Action::SecurityEventNotification => {
592 crate::decode::transcode::<SecurityEventNotificationResponse>(payload, options)
593 }
594 Action::SendLocalList => {
595 crate::decode::transcode::<SendLocalListResponse>(payload, options)
596 }
597 Action::SetChargingProfile => {
598 crate::decode::transcode::<SetChargingProfileResponse>(payload, options)
599 }
600 Action::SignCertificate => {
601 crate::decode::transcode::<SignCertificateResponse>(payload, options)
602 }
603 Action::SignedFirmwareStatusNotification => {
604 crate::decode::transcode::<SignedFirmwareStatusNotificationResponse>(payload, options)
605 }
606 Action::SignedUpdateFirmware => {
607 crate::decode::transcode::<SignedUpdateFirmwareResponse>(payload, options)
608 }
609 Action::StartTransaction => {
610 crate::decode::transcode::<StartTransactionResponse>(payload, options)
611 }
612 Action::StatusNotification => {
613 crate::decode::transcode::<StatusNotificationResponse>(payload, options)
614 }
615 Action::StopTransaction => {
616 crate::decode::transcode::<StopTransactionResponse>(payload, options)
617 }
618 Action::TriggerMessage => {
619 crate::decode::transcode::<TriggerMessageResponse>(payload, options)
620 }
621 Action::UnlockConnector => {
622 crate::decode::transcode::<UnlockConnectorResponse>(payload, options)
623 }
624 Action::UpdateFirmware => {
625 crate::decode::transcode::<UpdateFirmwareResponse>(payload, options)
626 }
627 }
628}
629
630#[derive(Clone, Debug, PartialEq)]
632#[non_exhaustive]
633#[allow(clippy::large_enum_variant)]
634pub enum CsRequest {
635 Authorize(AuthorizeRequest),
637 BootNotification(BootNotificationRequest),
639 DataTransfer(DataTransferRequest),
641 DiagnosticsStatusNotification(DiagnosticsStatusNotificationRequest),
643 FirmwareStatusNotification(FirmwareStatusNotificationRequest),
645 Heartbeat(HeartbeatRequest),
647 LogStatusNotification(LogStatusNotificationRequest),
649 MeterValues(MeterValuesRequest),
651 SecurityEventNotification(SecurityEventNotificationRequest),
653 SignCertificate(SignCertificateRequest),
655 SignedFirmwareStatusNotification(SignedFirmwareStatusNotificationRequest),
657 StartTransaction(StartTransactionRequest),
659 StatusNotification(StatusNotificationRequest),
661 StopTransaction(StopTransactionRequest),
663}
664
665impl CsRequest {
666 #[must_use]
668 pub const fn action(&self) -> Action {
669 match self {
670 Self::Authorize(_) => Action::Authorize,
671 Self::BootNotification(_) => Action::BootNotification,
672 Self::DataTransfer(_) => Action::DataTransfer,
673 Self::DiagnosticsStatusNotification(_) => Action::DiagnosticsStatusNotification,
674 Self::FirmwareStatusNotification(_) => Action::FirmwareStatusNotification,
675 Self::Heartbeat(_) => Action::Heartbeat,
676 Self::LogStatusNotification(_) => Action::LogStatusNotification,
677 Self::MeterValues(_) => Action::MeterValues,
678 Self::SecurityEventNotification(_) => Action::SecurityEventNotification,
679 Self::SignCertificate(_) => Action::SignCertificate,
680 Self::SignedFirmwareStatusNotification(_) => Action::SignedFirmwareStatusNotification,
681 Self::StartTransaction(_) => Action::StartTransaction,
682 Self::StatusNotification(_) => Action::StatusNotification,
683 Self::StopTransaction(_) => Action::StopTransaction,
684 }
685 }
686
687 pub fn decode(
690 action: Action,
691 payload: &RawValue,
692 options: &DecodeOptions,
693 ) -> Result<Self, DecodeError> {
694 Ok(match action {
695 Action::Authorize => Self::Authorize(
696 crate::decode::decode_payload::<AuthorizeRequest>(payload, options)?,
697 ),
698 Action::BootNotification => Self::BootNotification(crate::decode::decode_payload::<
699 BootNotificationRequest,
700 >(payload, options)?),
701 Action::DataTransfer => Self::DataTransfer(crate::decode::decode_payload::<
702 DataTransferRequest,
703 >(payload, options)?),
704 Action::DiagnosticsStatusNotification => {
705 Self::DiagnosticsStatusNotification(crate::decode::decode_payload::<
706 DiagnosticsStatusNotificationRequest,
707 >(payload, options)?)
708 }
709 Action::FirmwareStatusNotification => {
710 Self::FirmwareStatusNotification(crate::decode::decode_payload::<
711 FirmwareStatusNotificationRequest,
712 >(payload, options)?)
713 }
714 Action::Heartbeat => Self::Heartbeat(
715 crate::decode::decode_payload::<HeartbeatRequest>(payload, options)?,
716 ),
717 Action::LogStatusNotification => {
718 Self::LogStatusNotification(crate::decode::decode_payload::<
719 LogStatusNotificationRequest,
720 >(payload, options)?)
721 }
722 Action::MeterValues => Self::MeterValues(crate::decode::decode_payload::<
723 MeterValuesRequest,
724 >(payload, options)?),
725 Action::SecurityEventNotification => {
726 Self::SecurityEventNotification(crate::decode::decode_payload::<
727 SecurityEventNotificationRequest,
728 >(payload, options)?)
729 }
730 Action::SignCertificate => Self::SignCertificate(crate::decode::decode_payload::<
731 SignCertificateRequest,
732 >(payload, options)?),
733 Action::SignedFirmwareStatusNotification => {
734 Self::SignedFirmwareStatusNotification(crate::decode::decode_payload::<
735 SignedFirmwareStatusNotificationRequest,
736 >(payload, options)?)
737 }
738 Action::StartTransaction => Self::StartTransaction(crate::decode::decode_payload::<
739 StartTransactionRequest,
740 >(payload, options)?),
741 Action::StatusNotification => Self::StatusNotification(
742 crate::decode::decode_payload::<StatusNotificationRequest>(payload, options)?,
743 ),
744 Action::StopTransaction => Self::StopTransaction(crate::decode::decode_payload::<
745 StopTransactionRequest,
746 >(payload, options)?),
747 other => return Err(DecodeError::unsupported_action(other.as_str())),
748 })
749 }
750
751 pub fn decode_reporting(
754 action: Action,
755 payload: &RawValue,
756 options: &DecodeOptions,
757 ) -> Result<crate::decode::Decoded<Self>, DecodeError> {
758 Ok(match action {
759 Action::Authorize => {
760 crate::decode::decode_payload_reporting::<AuthorizeRequest>(payload, options)?
761 .map(Self::Authorize)
762 }
763 Action::BootNotification => crate::decode::decode_payload_reporting::<
764 BootNotificationRequest,
765 >(payload, options)?
766 .map(Self::BootNotification),
767 Action::DataTransfer => {
768 crate::decode::decode_payload_reporting::<DataTransferRequest>(payload, options)?
769 .map(Self::DataTransfer)
770 }
771 Action::DiagnosticsStatusNotification => crate::decode::decode_payload_reporting::<
772 DiagnosticsStatusNotificationRequest,
773 >(payload, options)?
774 .map(Self::DiagnosticsStatusNotification),
775 Action::FirmwareStatusNotification => crate::decode::decode_payload_reporting::<
776 FirmwareStatusNotificationRequest,
777 >(payload, options)?
778 .map(Self::FirmwareStatusNotification),
779 Action::Heartbeat => {
780 crate::decode::decode_payload_reporting::<HeartbeatRequest>(payload, options)?
781 .map(Self::Heartbeat)
782 }
783 Action::LogStatusNotification => crate::decode::decode_payload_reporting::<
784 LogStatusNotificationRequest,
785 >(payload, options)?
786 .map(Self::LogStatusNotification),
787 Action::MeterValues => {
788 crate::decode::decode_payload_reporting::<MeterValuesRequest>(payload, options)?
789 .map(Self::MeterValues)
790 }
791 Action::SecurityEventNotification => crate::decode::decode_payload_reporting::<
792 SecurityEventNotificationRequest,
793 >(payload, options)?
794 .map(Self::SecurityEventNotification),
795 Action::SignCertificate => {
796 crate::decode::decode_payload_reporting::<SignCertificateRequest>(payload, options)?
797 .map(Self::SignCertificate)
798 }
799 Action::SignedFirmwareStatusNotification => crate::decode::decode_payload_reporting::<
800 SignedFirmwareStatusNotificationRequest,
801 >(payload, options)?
802 .map(Self::SignedFirmwareStatusNotification),
803 Action::StartTransaction => crate::decode::decode_payload_reporting::<
804 StartTransactionRequest,
805 >(payload, options)?
806 .map(Self::StartTransaction),
807 Action::StatusNotification => crate::decode::decode_payload_reporting::<
808 StatusNotificationRequest,
809 >(payload, options)?
810 .map(Self::StatusNotification),
811 Action::StopTransaction => {
812 crate::decode::decode_payload_reporting::<StopTransactionRequest>(payload, options)?
813 .map(Self::StopTransaction)
814 }
815 other => return Err(DecodeError::unsupported_action(other.as_str())),
816 })
817 }
818
819 pub fn to_json(&self) -> Result<alloc::string::String, serde_json::Error> {
821 match self {
822 Self::Authorize(p) => serde_json::to_string(p),
823 Self::BootNotification(p) => serde_json::to_string(p),
824 Self::DataTransfer(p) => serde_json::to_string(p),
825 Self::DiagnosticsStatusNotification(p) => serde_json::to_string(p),
826 Self::FirmwareStatusNotification(p) => serde_json::to_string(p),
827 Self::Heartbeat(p) => serde_json::to_string(p),
828 Self::LogStatusNotification(p) => serde_json::to_string(p),
829 Self::MeterValues(p) => serde_json::to_string(p),
830 Self::SecurityEventNotification(p) => serde_json::to_string(p),
831 Self::SignCertificate(p) => serde_json::to_string(p),
832 Self::SignedFirmwareStatusNotification(p) => serde_json::to_string(p),
833 Self::StartTransaction(p) => serde_json::to_string(p),
834 Self::StatusNotification(p) => serde_json::to_string(p),
835 Self::StopTransaction(p) => serde_json::to_string(p),
836 }
837 }
838}
839
840impl Validate for CsRequest {
841 fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
842 match self {
843 Self::Authorize(p) => p.validate_at(path, out),
844 Self::BootNotification(p) => p.validate_at(path, out),
845 Self::DataTransfer(p) => p.validate_at(path, out),
846 Self::DiagnosticsStatusNotification(p) => p.validate_at(path, out),
847 Self::FirmwareStatusNotification(p) => p.validate_at(path, out),
848 Self::Heartbeat(p) => p.validate_at(path, out),
849 Self::LogStatusNotification(p) => p.validate_at(path, out),
850 Self::MeterValues(p) => p.validate_at(path, out),
851 Self::SecurityEventNotification(p) => p.validate_at(path, out),
852 Self::SignCertificate(p) => p.validate_at(path, out),
853 Self::SignedFirmwareStatusNotification(p) => p.validate_at(path, out),
854 Self::StartTransaction(p) => p.validate_at(path, out),
855 Self::StatusNotification(p) => p.validate_at(path, out),
856 Self::StopTransaction(p) => p.validate_at(path, out),
857 }
858 }
859}
860
861impl serde::Serialize for CsRequest {
862 fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
863 match self {
864 Self::Authorize(p) => p.serialize(ser),
865 Self::BootNotification(p) => p.serialize(ser),
866 Self::DataTransfer(p) => p.serialize(ser),
867 Self::DiagnosticsStatusNotification(p) => p.serialize(ser),
868 Self::FirmwareStatusNotification(p) => p.serialize(ser),
869 Self::Heartbeat(p) => p.serialize(ser),
870 Self::LogStatusNotification(p) => p.serialize(ser),
871 Self::MeterValues(p) => p.serialize(ser),
872 Self::SecurityEventNotification(p) => p.serialize(ser),
873 Self::SignCertificate(p) => p.serialize(ser),
874 Self::SignedFirmwareStatusNotification(p) => p.serialize(ser),
875 Self::StartTransaction(p) => p.serialize(ser),
876 Self::StatusNotification(p) => p.serialize(ser),
877 Self::StopTransaction(p) => p.serialize(ser),
878 }
879 }
880}
881
882impl crate::message::Sealed for CsRequest {}
883
884impl crate::message::DecodeRequest for CsRequest {
885 type Action = Action;
886
887 fn decode_reporting(
888 action: Action,
889 payload: &RawValue,
890 options: &DecodeOptions,
891 ) -> Result<crate::decode::Decoded<Self>, DecodeError> {
892 CsRequest::decode_reporting(action, payload, options)
893 }
894}
895
896#[derive(Clone, Debug, PartialEq)]
900#[non_exhaustive]
901#[allow(clippy::large_enum_variant)]
902pub enum CsResponse {
903 Authorize(AuthorizeResponse),
905 BootNotification(BootNotificationResponse),
907 DataTransfer(DataTransferResponse),
909 DiagnosticsStatusNotification(DiagnosticsStatusNotificationResponse),
911 FirmwareStatusNotification(FirmwareStatusNotificationResponse),
913 Heartbeat(HeartbeatResponse),
915 LogStatusNotification(LogStatusNotificationResponse),
917 MeterValues(MeterValuesResponse),
919 SecurityEventNotification(SecurityEventNotificationResponse),
921 SignCertificate(SignCertificateResponse),
923 SignedFirmwareStatusNotification(SignedFirmwareStatusNotificationResponse),
925 StartTransaction(StartTransactionResponse),
927 StatusNotification(StatusNotificationResponse),
929 StopTransaction(StopTransactionResponse),
931}
932
933impl CsResponse {
934 #[must_use]
936 pub const fn action(&self) -> Action {
937 match self {
938 Self::Authorize(_) => Action::Authorize,
939 Self::BootNotification(_) => Action::BootNotification,
940 Self::DataTransfer(_) => Action::DataTransfer,
941 Self::DiagnosticsStatusNotification(_) => Action::DiagnosticsStatusNotification,
942 Self::FirmwareStatusNotification(_) => Action::FirmwareStatusNotification,
943 Self::Heartbeat(_) => Action::Heartbeat,
944 Self::LogStatusNotification(_) => Action::LogStatusNotification,
945 Self::MeterValues(_) => Action::MeterValues,
946 Self::SecurityEventNotification(_) => Action::SecurityEventNotification,
947 Self::SignCertificate(_) => Action::SignCertificate,
948 Self::SignedFirmwareStatusNotification(_) => Action::SignedFirmwareStatusNotification,
949 Self::StartTransaction(_) => Action::StartTransaction,
950 Self::StatusNotification(_) => Action::StatusNotification,
951 Self::StopTransaction(_) => Action::StopTransaction,
952 }
953 }
954
955 pub fn decode(
958 action: Action,
959 payload: &RawValue,
960 options: &DecodeOptions,
961 ) -> Result<Self, DecodeError> {
962 Ok(match action {
963 Action::Authorize => Self::Authorize(
964 crate::decode::decode_payload::<AuthorizeResponse>(payload, options)?,
965 ),
966 Action::BootNotification => Self::BootNotification(crate::decode::decode_payload::<
967 BootNotificationResponse,
968 >(payload, options)?),
969 Action::DataTransfer => Self::DataTransfer(crate::decode::decode_payload::<
970 DataTransferResponse,
971 >(payload, options)?),
972 Action::DiagnosticsStatusNotification => {
973 Self::DiagnosticsStatusNotification(crate::decode::decode_payload::<
974 DiagnosticsStatusNotificationResponse,
975 >(payload, options)?)
976 }
977 Action::FirmwareStatusNotification => {
978 Self::FirmwareStatusNotification(crate::decode::decode_payload::<
979 FirmwareStatusNotificationResponse,
980 >(payload, options)?)
981 }
982 Action::Heartbeat => Self::Heartbeat(
983 crate::decode::decode_payload::<HeartbeatResponse>(payload, options)?,
984 ),
985 Action::LogStatusNotification => {
986 Self::LogStatusNotification(crate::decode::decode_payload::<
987 LogStatusNotificationResponse,
988 >(payload, options)?)
989 }
990 Action::MeterValues => Self::MeterValues(crate::decode::decode_payload::<
991 MeterValuesResponse,
992 >(payload, options)?),
993 Action::SecurityEventNotification => {
994 Self::SecurityEventNotification(crate::decode::decode_payload::<
995 SecurityEventNotificationResponse,
996 >(payload, options)?)
997 }
998 Action::SignCertificate => Self::SignCertificate(crate::decode::decode_payload::<
999 SignCertificateResponse,
1000 >(payload, options)?),
1001 Action::SignedFirmwareStatusNotification => {
1002 Self::SignedFirmwareStatusNotification(crate::decode::decode_payload::<
1003 SignedFirmwareStatusNotificationResponse,
1004 >(payload, options)?)
1005 }
1006 Action::StartTransaction => Self::StartTransaction(crate::decode::decode_payload::<
1007 StartTransactionResponse,
1008 >(payload, options)?),
1009 Action::StatusNotification => Self::StatusNotification(
1010 crate::decode::decode_payload::<StatusNotificationResponse>(payload, options)?,
1011 ),
1012 Action::StopTransaction => Self::StopTransaction(crate::decode::decode_payload::<
1013 StopTransactionResponse,
1014 >(payload, options)?),
1015 other => return Err(DecodeError::unsupported_action(other.as_str())),
1016 })
1017 }
1018
1019 pub fn to_json(&self) -> Result<alloc::string::String, serde_json::Error> {
1021 match self {
1022 Self::Authorize(p) => serde_json::to_string(p),
1023 Self::BootNotification(p) => serde_json::to_string(p),
1024 Self::DataTransfer(p) => serde_json::to_string(p),
1025 Self::DiagnosticsStatusNotification(p) => serde_json::to_string(p),
1026 Self::FirmwareStatusNotification(p) => serde_json::to_string(p),
1027 Self::Heartbeat(p) => serde_json::to_string(p),
1028 Self::LogStatusNotification(p) => serde_json::to_string(p),
1029 Self::MeterValues(p) => serde_json::to_string(p),
1030 Self::SecurityEventNotification(p) => serde_json::to_string(p),
1031 Self::SignCertificate(p) => serde_json::to_string(p),
1032 Self::SignedFirmwareStatusNotification(p) => serde_json::to_string(p),
1033 Self::StartTransaction(p) => serde_json::to_string(p),
1034 Self::StatusNotification(p) => serde_json::to_string(p),
1035 Self::StopTransaction(p) => serde_json::to_string(p),
1036 }
1037 }
1038}
1039
1040impl Validate for CsResponse {
1041 fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
1042 match self {
1043 Self::Authorize(p) => p.validate_at(path, out),
1044 Self::BootNotification(p) => p.validate_at(path, out),
1045 Self::DataTransfer(p) => p.validate_at(path, out),
1046 Self::DiagnosticsStatusNotification(p) => p.validate_at(path, out),
1047 Self::FirmwareStatusNotification(p) => p.validate_at(path, out),
1048 Self::Heartbeat(p) => p.validate_at(path, out),
1049 Self::LogStatusNotification(p) => p.validate_at(path, out),
1050 Self::MeterValues(p) => p.validate_at(path, out),
1051 Self::SecurityEventNotification(p) => p.validate_at(path, out),
1052 Self::SignCertificate(p) => p.validate_at(path, out),
1053 Self::SignedFirmwareStatusNotification(p) => p.validate_at(path, out),
1054 Self::StartTransaction(p) => p.validate_at(path, out),
1055 Self::StatusNotification(p) => p.validate_at(path, out),
1056 Self::StopTransaction(p) => p.validate_at(path, out),
1057 }
1058 }
1059}
1060
1061impl serde::Serialize for CsResponse {
1062 fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
1063 match self {
1064 Self::Authorize(p) => p.serialize(ser),
1065 Self::BootNotification(p) => p.serialize(ser),
1066 Self::DataTransfer(p) => p.serialize(ser),
1067 Self::DiagnosticsStatusNotification(p) => p.serialize(ser),
1068 Self::FirmwareStatusNotification(p) => p.serialize(ser),
1069 Self::Heartbeat(p) => p.serialize(ser),
1070 Self::LogStatusNotification(p) => p.serialize(ser),
1071 Self::MeterValues(p) => p.serialize(ser),
1072 Self::SecurityEventNotification(p) => p.serialize(ser),
1073 Self::SignCertificate(p) => p.serialize(ser),
1074 Self::SignedFirmwareStatusNotification(p) => p.serialize(ser),
1075 Self::StartTransaction(p) => p.serialize(ser),
1076 Self::StatusNotification(p) => p.serialize(ser),
1077 Self::StopTransaction(p) => p.serialize(ser),
1078 }
1079 }
1080}
1081
1082#[derive(Clone, Debug, PartialEq)]
1084#[non_exhaustive]
1085#[allow(clippy::large_enum_variant)]
1086pub enum CsmsRequest {
1087 CancelReservation(CancelReservationRequest),
1089 CertificateSigned(CertificateSignedRequest),
1091 ChangeAvailability(ChangeAvailabilityRequest),
1093 ChangeConfiguration(ChangeConfigurationRequest),
1095 ClearCache(ClearCacheRequest),
1097 ClearChargingProfile(ClearChargingProfileRequest),
1099 DataTransfer(DataTransferRequest),
1101 DeleteCertificate(DeleteCertificateRequest),
1103 ExtendedTriggerMessage(ExtendedTriggerMessageRequest),
1105 GetCompositeSchedule(GetCompositeScheduleRequest),
1107 GetConfiguration(GetConfigurationRequest),
1109 GetDiagnostics(GetDiagnosticsRequest),
1111 GetInstalledCertificateIds(GetInstalledCertificateIdsRequest),
1113 GetLocalListVersion(GetLocalListVersionRequest),
1115 GetLog(GetLogRequest),
1117 InstallCertificate(InstallCertificateRequest),
1119 RemoteStartTransaction(RemoteStartTransactionRequest),
1121 RemoteStopTransaction(RemoteStopTransactionRequest),
1123 ReserveNow(ReserveNowRequest),
1125 Reset(ResetRequest),
1127 SendLocalList(SendLocalListRequest),
1129 SetChargingProfile(SetChargingProfileRequest),
1131 SignedUpdateFirmware(SignedUpdateFirmwareRequest),
1133 TriggerMessage(TriggerMessageRequest),
1135 UnlockConnector(UnlockConnectorRequest),
1137 UpdateFirmware(UpdateFirmwareRequest),
1139}
1140
1141impl CsmsRequest {
1142 #[must_use]
1144 pub const fn action(&self) -> Action {
1145 match self {
1146 Self::CancelReservation(_) => Action::CancelReservation,
1147 Self::CertificateSigned(_) => Action::CertificateSigned,
1148 Self::ChangeAvailability(_) => Action::ChangeAvailability,
1149 Self::ChangeConfiguration(_) => Action::ChangeConfiguration,
1150 Self::ClearCache(_) => Action::ClearCache,
1151 Self::ClearChargingProfile(_) => Action::ClearChargingProfile,
1152 Self::DataTransfer(_) => Action::DataTransfer,
1153 Self::DeleteCertificate(_) => Action::DeleteCertificate,
1154 Self::ExtendedTriggerMessage(_) => Action::ExtendedTriggerMessage,
1155 Self::GetCompositeSchedule(_) => Action::GetCompositeSchedule,
1156 Self::GetConfiguration(_) => Action::GetConfiguration,
1157 Self::GetDiagnostics(_) => Action::GetDiagnostics,
1158 Self::GetInstalledCertificateIds(_) => Action::GetInstalledCertificateIds,
1159 Self::GetLocalListVersion(_) => Action::GetLocalListVersion,
1160 Self::GetLog(_) => Action::GetLog,
1161 Self::InstallCertificate(_) => Action::InstallCertificate,
1162 Self::RemoteStartTransaction(_) => Action::RemoteStartTransaction,
1163 Self::RemoteStopTransaction(_) => Action::RemoteStopTransaction,
1164 Self::ReserveNow(_) => Action::ReserveNow,
1165 Self::Reset(_) => Action::Reset,
1166 Self::SendLocalList(_) => Action::SendLocalList,
1167 Self::SetChargingProfile(_) => Action::SetChargingProfile,
1168 Self::SignedUpdateFirmware(_) => Action::SignedUpdateFirmware,
1169 Self::TriggerMessage(_) => Action::TriggerMessage,
1170 Self::UnlockConnector(_) => Action::UnlockConnector,
1171 Self::UpdateFirmware(_) => Action::UpdateFirmware,
1172 }
1173 }
1174
1175 pub fn decode(
1178 action: Action,
1179 payload: &RawValue,
1180 options: &DecodeOptions,
1181 ) -> Result<Self, DecodeError> {
1182 Ok(match action {
1183 Action::CancelReservation => Self::CancelReservation(crate::decode::decode_payload::<
1184 CancelReservationRequest,
1185 >(payload, options)?),
1186 Action::CertificateSigned => Self::CertificateSigned(crate::decode::decode_payload::<
1187 CertificateSignedRequest,
1188 >(payload, options)?),
1189 Action::ChangeAvailability => Self::ChangeAvailability(
1190 crate::decode::decode_payload::<ChangeAvailabilityRequest>(payload, options)?,
1191 ),
1192 Action::ChangeConfiguration => {
1193 Self::ChangeConfiguration(crate::decode::decode_payload::<
1194 ChangeConfigurationRequest,
1195 >(payload, options)?)
1196 }
1197 Action::ClearCache => Self::ClearCache(crate::decode::decode_payload::<
1198 ClearCacheRequest,
1199 >(payload, options)?),
1200 Action::ClearChargingProfile => {
1201 Self::ClearChargingProfile(crate::decode::decode_payload::<
1202 ClearChargingProfileRequest,
1203 >(payload, options)?)
1204 }
1205 Action::DataTransfer => Self::DataTransfer(crate::decode::decode_payload::<
1206 DataTransferRequest,
1207 >(payload, options)?),
1208 Action::DeleteCertificate => Self::DeleteCertificate(crate::decode::decode_payload::<
1209 DeleteCertificateRequest,
1210 >(payload, options)?),
1211 Action::ExtendedTriggerMessage => {
1212 Self::ExtendedTriggerMessage(crate::decode::decode_payload::<
1213 ExtendedTriggerMessageRequest,
1214 >(payload, options)?)
1215 }
1216 Action::GetCompositeSchedule => {
1217 Self::GetCompositeSchedule(crate::decode::decode_payload::<
1218 GetCompositeScheduleRequest,
1219 >(payload, options)?)
1220 }
1221 Action::GetConfiguration => Self::GetConfiguration(crate::decode::decode_payload::<
1222 GetConfigurationRequest,
1223 >(payload, options)?),
1224 Action::GetDiagnostics => Self::GetDiagnostics(crate::decode::decode_payload::<
1225 GetDiagnosticsRequest,
1226 >(payload, options)?),
1227 Action::GetInstalledCertificateIds => {
1228 Self::GetInstalledCertificateIds(crate::decode::decode_payload::<
1229 GetInstalledCertificateIdsRequest,
1230 >(payload, options)?)
1231 }
1232 Action::GetLocalListVersion => {
1233 Self::GetLocalListVersion(crate::decode::decode_payload::<
1234 GetLocalListVersionRequest,
1235 >(payload, options)?)
1236 }
1237 Action::GetLog => Self::GetLog(crate::decode::decode_payload::<GetLogRequest>(
1238 payload, options,
1239 )?),
1240 Action::InstallCertificate => Self::InstallCertificate(
1241 crate::decode::decode_payload::<InstallCertificateRequest>(payload, options)?,
1242 ),
1243 Action::RemoteStartTransaction => {
1244 Self::RemoteStartTransaction(crate::decode::decode_payload::<
1245 RemoteStartTransactionRequest,
1246 >(payload, options)?)
1247 }
1248 Action::RemoteStopTransaction => {
1249 Self::RemoteStopTransaction(crate::decode::decode_payload::<
1250 RemoteStopTransactionRequest,
1251 >(payload, options)?)
1252 }
1253 Action::ReserveNow => Self::ReserveNow(crate::decode::decode_payload::<
1254 ReserveNowRequest,
1255 >(payload, options)?),
1256 Action::Reset => Self::Reset(crate::decode::decode_payload::<ResetRequest>(
1257 payload, options,
1258 )?),
1259 Action::SendLocalList => Self::SendLocalList(crate::decode::decode_payload::<
1260 SendLocalListRequest,
1261 >(payload, options)?),
1262 Action::SetChargingProfile => Self::SetChargingProfile(
1263 crate::decode::decode_payload::<SetChargingProfileRequest>(payload, options)?,
1264 ),
1265 Action::SignedUpdateFirmware => {
1266 Self::SignedUpdateFirmware(crate::decode::decode_payload::<
1267 SignedUpdateFirmwareRequest,
1268 >(payload, options)?)
1269 }
1270 Action::TriggerMessage => Self::TriggerMessage(crate::decode::decode_payload::<
1271 TriggerMessageRequest,
1272 >(payload, options)?),
1273 Action::UnlockConnector => Self::UnlockConnector(crate::decode::decode_payload::<
1274 UnlockConnectorRequest,
1275 >(payload, options)?),
1276 Action::UpdateFirmware => Self::UpdateFirmware(crate::decode::decode_payload::<
1277 UpdateFirmwareRequest,
1278 >(payload, options)?),
1279 other => return Err(DecodeError::unsupported_action(other.as_str())),
1280 })
1281 }
1282
1283 pub fn decode_reporting(
1286 action: Action,
1287 payload: &RawValue,
1288 options: &DecodeOptions,
1289 ) -> Result<crate::decode::Decoded<Self>, DecodeError> {
1290 Ok(match action {
1291 Action::CancelReservation => crate::decode::decode_payload_reporting::<
1292 CancelReservationRequest,
1293 >(payload, options)?
1294 .map(Self::CancelReservation),
1295 Action::CertificateSigned => crate::decode::decode_payload_reporting::<
1296 CertificateSignedRequest,
1297 >(payload, options)?
1298 .map(Self::CertificateSigned),
1299 Action::ChangeAvailability => crate::decode::decode_payload_reporting::<
1300 ChangeAvailabilityRequest,
1301 >(payload, options)?
1302 .map(Self::ChangeAvailability),
1303 Action::ChangeConfiguration => crate::decode::decode_payload_reporting::<
1304 ChangeConfigurationRequest,
1305 >(payload, options)?
1306 .map(Self::ChangeConfiguration),
1307 Action::ClearCache => {
1308 crate::decode::decode_payload_reporting::<ClearCacheRequest>(payload, options)?
1309 .map(Self::ClearCache)
1310 }
1311 Action::ClearChargingProfile => crate::decode::decode_payload_reporting::<
1312 ClearChargingProfileRequest,
1313 >(payload, options)?
1314 .map(Self::ClearChargingProfile),
1315 Action::DataTransfer => {
1316 crate::decode::decode_payload_reporting::<DataTransferRequest>(payload, options)?
1317 .map(Self::DataTransfer)
1318 }
1319 Action::DeleteCertificate => crate::decode::decode_payload_reporting::<
1320 DeleteCertificateRequest,
1321 >(payload, options)?
1322 .map(Self::DeleteCertificate),
1323 Action::ExtendedTriggerMessage => crate::decode::decode_payload_reporting::<
1324 ExtendedTriggerMessageRequest,
1325 >(payload, options)?
1326 .map(Self::ExtendedTriggerMessage),
1327 Action::GetCompositeSchedule => crate::decode::decode_payload_reporting::<
1328 GetCompositeScheduleRequest,
1329 >(payload, options)?
1330 .map(Self::GetCompositeSchedule),
1331 Action::GetConfiguration => crate::decode::decode_payload_reporting::<
1332 GetConfigurationRequest,
1333 >(payload, options)?
1334 .map(Self::GetConfiguration),
1335 Action::GetDiagnostics => {
1336 crate::decode::decode_payload_reporting::<GetDiagnosticsRequest>(payload, options)?
1337 .map(Self::GetDiagnostics)
1338 }
1339 Action::GetInstalledCertificateIds => crate::decode::decode_payload_reporting::<
1340 GetInstalledCertificateIdsRequest,
1341 >(payload, options)?
1342 .map(Self::GetInstalledCertificateIds),
1343 Action::GetLocalListVersion => crate::decode::decode_payload_reporting::<
1344 GetLocalListVersionRequest,
1345 >(payload, options)?
1346 .map(Self::GetLocalListVersion),
1347 Action::GetLog => {
1348 crate::decode::decode_payload_reporting::<GetLogRequest>(payload, options)?
1349 .map(Self::GetLog)
1350 }
1351 Action::InstallCertificate => crate::decode::decode_payload_reporting::<
1352 InstallCertificateRequest,
1353 >(payload, options)?
1354 .map(Self::InstallCertificate),
1355 Action::RemoteStartTransaction => crate::decode::decode_payload_reporting::<
1356 RemoteStartTransactionRequest,
1357 >(payload, options)?
1358 .map(Self::RemoteStartTransaction),
1359 Action::RemoteStopTransaction => crate::decode::decode_payload_reporting::<
1360 RemoteStopTransactionRequest,
1361 >(payload, options)?
1362 .map(Self::RemoteStopTransaction),
1363 Action::ReserveNow => {
1364 crate::decode::decode_payload_reporting::<ReserveNowRequest>(payload, options)?
1365 .map(Self::ReserveNow)
1366 }
1367 Action::Reset => {
1368 crate::decode::decode_payload_reporting::<ResetRequest>(payload, options)?
1369 .map(Self::Reset)
1370 }
1371 Action::SendLocalList => {
1372 crate::decode::decode_payload_reporting::<SendLocalListRequest>(payload, options)?
1373 .map(Self::SendLocalList)
1374 }
1375 Action::SetChargingProfile => crate::decode::decode_payload_reporting::<
1376 SetChargingProfileRequest,
1377 >(payload, options)?
1378 .map(Self::SetChargingProfile),
1379 Action::SignedUpdateFirmware => crate::decode::decode_payload_reporting::<
1380 SignedUpdateFirmwareRequest,
1381 >(payload, options)?
1382 .map(Self::SignedUpdateFirmware),
1383 Action::TriggerMessage => {
1384 crate::decode::decode_payload_reporting::<TriggerMessageRequest>(payload, options)?
1385 .map(Self::TriggerMessage)
1386 }
1387 Action::UnlockConnector => {
1388 crate::decode::decode_payload_reporting::<UnlockConnectorRequest>(payload, options)?
1389 .map(Self::UnlockConnector)
1390 }
1391 Action::UpdateFirmware => {
1392 crate::decode::decode_payload_reporting::<UpdateFirmwareRequest>(payload, options)?
1393 .map(Self::UpdateFirmware)
1394 }
1395 other => return Err(DecodeError::unsupported_action(other.as_str())),
1396 })
1397 }
1398
1399 pub fn to_json(&self) -> Result<alloc::string::String, serde_json::Error> {
1401 match self {
1402 Self::CancelReservation(p) => serde_json::to_string(p),
1403 Self::CertificateSigned(p) => serde_json::to_string(p),
1404 Self::ChangeAvailability(p) => serde_json::to_string(p),
1405 Self::ChangeConfiguration(p) => serde_json::to_string(p),
1406 Self::ClearCache(p) => serde_json::to_string(p),
1407 Self::ClearChargingProfile(p) => serde_json::to_string(p),
1408 Self::DataTransfer(p) => serde_json::to_string(p),
1409 Self::DeleteCertificate(p) => serde_json::to_string(p),
1410 Self::ExtendedTriggerMessage(p) => serde_json::to_string(p),
1411 Self::GetCompositeSchedule(p) => serde_json::to_string(p),
1412 Self::GetConfiguration(p) => serde_json::to_string(p),
1413 Self::GetDiagnostics(p) => serde_json::to_string(p),
1414 Self::GetInstalledCertificateIds(p) => serde_json::to_string(p),
1415 Self::GetLocalListVersion(p) => serde_json::to_string(p),
1416 Self::GetLog(p) => serde_json::to_string(p),
1417 Self::InstallCertificate(p) => serde_json::to_string(p),
1418 Self::RemoteStartTransaction(p) => serde_json::to_string(p),
1419 Self::RemoteStopTransaction(p) => serde_json::to_string(p),
1420 Self::ReserveNow(p) => serde_json::to_string(p),
1421 Self::Reset(p) => serde_json::to_string(p),
1422 Self::SendLocalList(p) => serde_json::to_string(p),
1423 Self::SetChargingProfile(p) => serde_json::to_string(p),
1424 Self::SignedUpdateFirmware(p) => serde_json::to_string(p),
1425 Self::TriggerMessage(p) => serde_json::to_string(p),
1426 Self::UnlockConnector(p) => serde_json::to_string(p),
1427 Self::UpdateFirmware(p) => serde_json::to_string(p),
1428 }
1429 }
1430}
1431
1432impl Validate for CsmsRequest {
1433 fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
1434 match self {
1435 Self::CancelReservation(p) => p.validate_at(path, out),
1436 Self::CertificateSigned(p) => p.validate_at(path, out),
1437 Self::ChangeAvailability(p) => p.validate_at(path, out),
1438 Self::ChangeConfiguration(p) => p.validate_at(path, out),
1439 Self::ClearCache(p) => p.validate_at(path, out),
1440 Self::ClearChargingProfile(p) => p.validate_at(path, out),
1441 Self::DataTransfer(p) => p.validate_at(path, out),
1442 Self::DeleteCertificate(p) => p.validate_at(path, out),
1443 Self::ExtendedTriggerMessage(p) => p.validate_at(path, out),
1444 Self::GetCompositeSchedule(p) => p.validate_at(path, out),
1445 Self::GetConfiguration(p) => p.validate_at(path, out),
1446 Self::GetDiagnostics(p) => p.validate_at(path, out),
1447 Self::GetInstalledCertificateIds(p) => p.validate_at(path, out),
1448 Self::GetLocalListVersion(p) => p.validate_at(path, out),
1449 Self::GetLog(p) => p.validate_at(path, out),
1450 Self::InstallCertificate(p) => p.validate_at(path, out),
1451 Self::RemoteStartTransaction(p) => p.validate_at(path, out),
1452 Self::RemoteStopTransaction(p) => p.validate_at(path, out),
1453 Self::ReserveNow(p) => p.validate_at(path, out),
1454 Self::Reset(p) => p.validate_at(path, out),
1455 Self::SendLocalList(p) => p.validate_at(path, out),
1456 Self::SetChargingProfile(p) => p.validate_at(path, out),
1457 Self::SignedUpdateFirmware(p) => p.validate_at(path, out),
1458 Self::TriggerMessage(p) => p.validate_at(path, out),
1459 Self::UnlockConnector(p) => p.validate_at(path, out),
1460 Self::UpdateFirmware(p) => p.validate_at(path, out),
1461 }
1462 }
1463}
1464
1465impl serde::Serialize for CsmsRequest {
1466 fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
1467 match self {
1468 Self::CancelReservation(p) => p.serialize(ser),
1469 Self::CertificateSigned(p) => p.serialize(ser),
1470 Self::ChangeAvailability(p) => p.serialize(ser),
1471 Self::ChangeConfiguration(p) => p.serialize(ser),
1472 Self::ClearCache(p) => p.serialize(ser),
1473 Self::ClearChargingProfile(p) => p.serialize(ser),
1474 Self::DataTransfer(p) => p.serialize(ser),
1475 Self::DeleteCertificate(p) => p.serialize(ser),
1476 Self::ExtendedTriggerMessage(p) => p.serialize(ser),
1477 Self::GetCompositeSchedule(p) => p.serialize(ser),
1478 Self::GetConfiguration(p) => p.serialize(ser),
1479 Self::GetDiagnostics(p) => p.serialize(ser),
1480 Self::GetInstalledCertificateIds(p) => p.serialize(ser),
1481 Self::GetLocalListVersion(p) => p.serialize(ser),
1482 Self::GetLog(p) => p.serialize(ser),
1483 Self::InstallCertificate(p) => p.serialize(ser),
1484 Self::RemoteStartTransaction(p) => p.serialize(ser),
1485 Self::RemoteStopTransaction(p) => p.serialize(ser),
1486 Self::ReserveNow(p) => p.serialize(ser),
1487 Self::Reset(p) => p.serialize(ser),
1488 Self::SendLocalList(p) => p.serialize(ser),
1489 Self::SetChargingProfile(p) => p.serialize(ser),
1490 Self::SignedUpdateFirmware(p) => p.serialize(ser),
1491 Self::TriggerMessage(p) => p.serialize(ser),
1492 Self::UnlockConnector(p) => p.serialize(ser),
1493 Self::UpdateFirmware(p) => p.serialize(ser),
1494 }
1495 }
1496}
1497
1498impl crate::message::Sealed for CsmsRequest {}
1499
1500impl crate::message::DecodeRequest for CsmsRequest {
1501 type Action = Action;
1502
1503 fn decode_reporting(
1504 action: Action,
1505 payload: &RawValue,
1506 options: &DecodeOptions,
1507 ) -> Result<crate::decode::Decoded<Self>, DecodeError> {
1508 CsmsRequest::decode_reporting(action, payload, options)
1509 }
1510}
1511
1512#[derive(Clone, Debug, PartialEq)]
1514#[non_exhaustive]
1515#[allow(clippy::large_enum_variant)]
1516pub enum CsmsResponse {
1517 CancelReservation(CancelReservationResponse),
1519 CertificateSigned(CertificateSignedResponse),
1521 ChangeAvailability(ChangeAvailabilityResponse),
1523 ChangeConfiguration(ChangeConfigurationResponse),
1525 ClearCache(ClearCacheResponse),
1527 ClearChargingProfile(ClearChargingProfileResponse),
1529 DataTransfer(DataTransferResponse),
1531 DeleteCertificate(DeleteCertificateResponse),
1533 ExtendedTriggerMessage(ExtendedTriggerMessageResponse),
1535 GetCompositeSchedule(GetCompositeScheduleResponse),
1537 GetConfiguration(GetConfigurationResponse),
1539 GetDiagnostics(GetDiagnosticsResponse),
1541 GetInstalledCertificateIds(GetInstalledCertificateIdsResponse),
1543 GetLocalListVersion(GetLocalListVersionResponse),
1545 GetLog(GetLogResponse),
1547 InstallCertificate(InstallCertificateResponse),
1549 RemoteStartTransaction(RemoteStartTransactionResponse),
1551 RemoteStopTransaction(RemoteStopTransactionResponse),
1553 ReserveNow(ReserveNowResponse),
1555 Reset(ResetResponse),
1557 SendLocalList(SendLocalListResponse),
1559 SetChargingProfile(SetChargingProfileResponse),
1561 SignedUpdateFirmware(SignedUpdateFirmwareResponse),
1563 TriggerMessage(TriggerMessageResponse),
1565 UnlockConnector(UnlockConnectorResponse),
1567 UpdateFirmware(UpdateFirmwareResponse),
1569}
1570
1571impl CsmsResponse {
1572 #[must_use]
1574 pub const fn action(&self) -> Action {
1575 match self {
1576 Self::CancelReservation(_) => Action::CancelReservation,
1577 Self::CertificateSigned(_) => Action::CertificateSigned,
1578 Self::ChangeAvailability(_) => Action::ChangeAvailability,
1579 Self::ChangeConfiguration(_) => Action::ChangeConfiguration,
1580 Self::ClearCache(_) => Action::ClearCache,
1581 Self::ClearChargingProfile(_) => Action::ClearChargingProfile,
1582 Self::DataTransfer(_) => Action::DataTransfer,
1583 Self::DeleteCertificate(_) => Action::DeleteCertificate,
1584 Self::ExtendedTriggerMessage(_) => Action::ExtendedTriggerMessage,
1585 Self::GetCompositeSchedule(_) => Action::GetCompositeSchedule,
1586 Self::GetConfiguration(_) => Action::GetConfiguration,
1587 Self::GetDiagnostics(_) => Action::GetDiagnostics,
1588 Self::GetInstalledCertificateIds(_) => Action::GetInstalledCertificateIds,
1589 Self::GetLocalListVersion(_) => Action::GetLocalListVersion,
1590 Self::GetLog(_) => Action::GetLog,
1591 Self::InstallCertificate(_) => Action::InstallCertificate,
1592 Self::RemoteStartTransaction(_) => Action::RemoteStartTransaction,
1593 Self::RemoteStopTransaction(_) => Action::RemoteStopTransaction,
1594 Self::ReserveNow(_) => Action::ReserveNow,
1595 Self::Reset(_) => Action::Reset,
1596 Self::SendLocalList(_) => Action::SendLocalList,
1597 Self::SetChargingProfile(_) => Action::SetChargingProfile,
1598 Self::SignedUpdateFirmware(_) => Action::SignedUpdateFirmware,
1599 Self::TriggerMessage(_) => Action::TriggerMessage,
1600 Self::UnlockConnector(_) => Action::UnlockConnector,
1601 Self::UpdateFirmware(_) => Action::UpdateFirmware,
1602 }
1603 }
1604
1605 pub fn decode(
1608 action: Action,
1609 payload: &RawValue,
1610 options: &DecodeOptions,
1611 ) -> Result<Self, DecodeError> {
1612 Ok(match action {
1613 Action::CancelReservation => Self::CancelReservation(crate::decode::decode_payload::<
1614 CancelReservationResponse,
1615 >(payload, options)?),
1616 Action::CertificateSigned => Self::CertificateSigned(crate::decode::decode_payload::<
1617 CertificateSignedResponse,
1618 >(payload, options)?),
1619 Action::ChangeAvailability => Self::ChangeAvailability(
1620 crate::decode::decode_payload::<ChangeAvailabilityResponse>(payload, options)?,
1621 ),
1622 Action::ChangeConfiguration => {
1623 Self::ChangeConfiguration(crate::decode::decode_payload::<
1624 ChangeConfigurationResponse,
1625 >(payload, options)?)
1626 }
1627 Action::ClearCache => Self::ClearCache(crate::decode::decode_payload::<
1628 ClearCacheResponse,
1629 >(payload, options)?),
1630 Action::ClearChargingProfile => {
1631 Self::ClearChargingProfile(crate::decode::decode_payload::<
1632 ClearChargingProfileResponse,
1633 >(payload, options)?)
1634 }
1635 Action::DataTransfer => Self::DataTransfer(crate::decode::decode_payload::<
1636 DataTransferResponse,
1637 >(payload, options)?),
1638 Action::DeleteCertificate => Self::DeleteCertificate(crate::decode::decode_payload::<
1639 DeleteCertificateResponse,
1640 >(payload, options)?),
1641 Action::ExtendedTriggerMessage => {
1642 Self::ExtendedTriggerMessage(crate::decode::decode_payload::<
1643 ExtendedTriggerMessageResponse,
1644 >(payload, options)?)
1645 }
1646 Action::GetCompositeSchedule => {
1647 Self::GetCompositeSchedule(crate::decode::decode_payload::<
1648 GetCompositeScheduleResponse,
1649 >(payload, options)?)
1650 }
1651 Action::GetConfiguration => Self::GetConfiguration(crate::decode::decode_payload::<
1652 GetConfigurationResponse,
1653 >(payload, options)?),
1654 Action::GetDiagnostics => Self::GetDiagnostics(crate::decode::decode_payload::<
1655 GetDiagnosticsResponse,
1656 >(payload, options)?),
1657 Action::GetInstalledCertificateIds => {
1658 Self::GetInstalledCertificateIds(crate::decode::decode_payload::<
1659 GetInstalledCertificateIdsResponse,
1660 >(payload, options)?)
1661 }
1662 Action::GetLocalListVersion => {
1663 Self::GetLocalListVersion(crate::decode::decode_payload::<
1664 GetLocalListVersionResponse,
1665 >(payload, options)?)
1666 }
1667 Action::GetLog => Self::GetLog(crate::decode::decode_payload::<GetLogResponse>(
1668 payload, options,
1669 )?),
1670 Action::InstallCertificate => Self::InstallCertificate(
1671 crate::decode::decode_payload::<InstallCertificateResponse>(payload, options)?,
1672 ),
1673 Action::RemoteStartTransaction => {
1674 Self::RemoteStartTransaction(crate::decode::decode_payload::<
1675 RemoteStartTransactionResponse,
1676 >(payload, options)?)
1677 }
1678 Action::RemoteStopTransaction => {
1679 Self::RemoteStopTransaction(crate::decode::decode_payload::<
1680 RemoteStopTransactionResponse,
1681 >(payload, options)?)
1682 }
1683 Action::ReserveNow => Self::ReserveNow(crate::decode::decode_payload::<
1684 ReserveNowResponse,
1685 >(payload, options)?),
1686 Action::Reset => Self::Reset(crate::decode::decode_payload::<ResetResponse>(
1687 payload, options,
1688 )?),
1689 Action::SendLocalList => Self::SendLocalList(crate::decode::decode_payload::<
1690 SendLocalListResponse,
1691 >(payload, options)?),
1692 Action::SetChargingProfile => Self::SetChargingProfile(
1693 crate::decode::decode_payload::<SetChargingProfileResponse>(payload, options)?,
1694 ),
1695 Action::SignedUpdateFirmware => {
1696 Self::SignedUpdateFirmware(crate::decode::decode_payload::<
1697 SignedUpdateFirmwareResponse,
1698 >(payload, options)?)
1699 }
1700 Action::TriggerMessage => Self::TriggerMessage(crate::decode::decode_payload::<
1701 TriggerMessageResponse,
1702 >(payload, options)?),
1703 Action::UnlockConnector => Self::UnlockConnector(crate::decode::decode_payload::<
1704 UnlockConnectorResponse,
1705 >(payload, options)?),
1706 Action::UpdateFirmware => Self::UpdateFirmware(crate::decode::decode_payload::<
1707 UpdateFirmwareResponse,
1708 >(payload, options)?),
1709 other => return Err(DecodeError::unsupported_action(other.as_str())),
1710 })
1711 }
1712
1713 pub fn to_json(&self) -> Result<alloc::string::String, serde_json::Error> {
1715 match self {
1716 Self::CancelReservation(p) => serde_json::to_string(p),
1717 Self::CertificateSigned(p) => serde_json::to_string(p),
1718 Self::ChangeAvailability(p) => serde_json::to_string(p),
1719 Self::ChangeConfiguration(p) => serde_json::to_string(p),
1720 Self::ClearCache(p) => serde_json::to_string(p),
1721 Self::ClearChargingProfile(p) => serde_json::to_string(p),
1722 Self::DataTransfer(p) => serde_json::to_string(p),
1723 Self::DeleteCertificate(p) => serde_json::to_string(p),
1724 Self::ExtendedTriggerMessage(p) => serde_json::to_string(p),
1725 Self::GetCompositeSchedule(p) => serde_json::to_string(p),
1726 Self::GetConfiguration(p) => serde_json::to_string(p),
1727 Self::GetDiagnostics(p) => serde_json::to_string(p),
1728 Self::GetInstalledCertificateIds(p) => serde_json::to_string(p),
1729 Self::GetLocalListVersion(p) => serde_json::to_string(p),
1730 Self::GetLog(p) => serde_json::to_string(p),
1731 Self::InstallCertificate(p) => serde_json::to_string(p),
1732 Self::RemoteStartTransaction(p) => serde_json::to_string(p),
1733 Self::RemoteStopTransaction(p) => serde_json::to_string(p),
1734 Self::ReserveNow(p) => serde_json::to_string(p),
1735 Self::Reset(p) => serde_json::to_string(p),
1736 Self::SendLocalList(p) => serde_json::to_string(p),
1737 Self::SetChargingProfile(p) => serde_json::to_string(p),
1738 Self::SignedUpdateFirmware(p) => serde_json::to_string(p),
1739 Self::TriggerMessage(p) => serde_json::to_string(p),
1740 Self::UnlockConnector(p) => serde_json::to_string(p),
1741 Self::UpdateFirmware(p) => serde_json::to_string(p),
1742 }
1743 }
1744}
1745
1746impl Validate for CsmsResponse {
1747 fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations) {
1748 match self {
1749 Self::CancelReservation(p) => p.validate_at(path, out),
1750 Self::CertificateSigned(p) => p.validate_at(path, out),
1751 Self::ChangeAvailability(p) => p.validate_at(path, out),
1752 Self::ChangeConfiguration(p) => p.validate_at(path, out),
1753 Self::ClearCache(p) => p.validate_at(path, out),
1754 Self::ClearChargingProfile(p) => p.validate_at(path, out),
1755 Self::DataTransfer(p) => p.validate_at(path, out),
1756 Self::DeleteCertificate(p) => p.validate_at(path, out),
1757 Self::ExtendedTriggerMessage(p) => p.validate_at(path, out),
1758 Self::GetCompositeSchedule(p) => p.validate_at(path, out),
1759 Self::GetConfiguration(p) => p.validate_at(path, out),
1760 Self::GetDiagnostics(p) => p.validate_at(path, out),
1761 Self::GetInstalledCertificateIds(p) => p.validate_at(path, out),
1762 Self::GetLocalListVersion(p) => p.validate_at(path, out),
1763 Self::GetLog(p) => p.validate_at(path, out),
1764 Self::InstallCertificate(p) => p.validate_at(path, out),
1765 Self::RemoteStartTransaction(p) => p.validate_at(path, out),
1766 Self::RemoteStopTransaction(p) => p.validate_at(path, out),
1767 Self::ReserveNow(p) => p.validate_at(path, out),
1768 Self::Reset(p) => p.validate_at(path, out),
1769 Self::SendLocalList(p) => p.validate_at(path, out),
1770 Self::SetChargingProfile(p) => p.validate_at(path, out),
1771 Self::SignedUpdateFirmware(p) => p.validate_at(path, out),
1772 Self::TriggerMessage(p) => p.validate_at(path, out),
1773 Self::UnlockConnector(p) => p.validate_at(path, out),
1774 Self::UpdateFirmware(p) => p.validate_at(path, out),
1775 }
1776 }
1777}
1778
1779impl serde::Serialize for CsmsResponse {
1780 fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
1781 match self {
1782 Self::CancelReservation(p) => p.serialize(ser),
1783 Self::CertificateSigned(p) => p.serialize(ser),
1784 Self::ChangeAvailability(p) => p.serialize(ser),
1785 Self::ChangeConfiguration(p) => p.serialize(ser),
1786 Self::ClearCache(p) => p.serialize(ser),
1787 Self::ClearChargingProfile(p) => p.serialize(ser),
1788 Self::DataTransfer(p) => p.serialize(ser),
1789 Self::DeleteCertificate(p) => p.serialize(ser),
1790 Self::ExtendedTriggerMessage(p) => p.serialize(ser),
1791 Self::GetCompositeSchedule(p) => p.serialize(ser),
1792 Self::GetConfiguration(p) => p.serialize(ser),
1793 Self::GetDiagnostics(p) => p.serialize(ser),
1794 Self::GetInstalledCertificateIds(p) => p.serialize(ser),
1795 Self::GetLocalListVersion(p) => p.serialize(ser),
1796 Self::GetLog(p) => p.serialize(ser),
1797 Self::InstallCertificate(p) => p.serialize(ser),
1798 Self::RemoteStartTransaction(p) => p.serialize(ser),
1799 Self::RemoteStopTransaction(p) => p.serialize(ser),
1800 Self::ReserveNow(p) => p.serialize(ser),
1801 Self::Reset(p) => p.serialize(ser),
1802 Self::SendLocalList(p) => p.serialize(ser),
1803 Self::SetChargingProfile(p) => p.serialize(ser),
1804 Self::SignedUpdateFirmware(p) => p.serialize(ser),
1805 Self::TriggerMessage(p) => p.serialize(ser),
1806 Self::UnlockConnector(p) => p.serialize(ser),
1807 Self::UpdateFirmware(p) => p.serialize(ser),
1808 }
1809 }
1810}