Skip to main content

ocpp_types/v21/
reset_request.rs

1// @generated by ocpp-codegen from schemas/. Do not edit by hand -- run
2// `scripts/generate.sh` to regenerate; manual changes will be overwritten.
3
4use super::common::*;
5#[derive(Debug, Clone, PartialEq, Eq)]
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7pub struct ResetRequest<CustomDataType = crate::NoCustomData> {
8    #[cfg_attr(feature = "serde", serde(rename = "customData"))]
9    #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
10    pub custom_data: Option<CustomDataType>,
11    /// This contains the ID of a specific EVSE that needs to be reset, instead of the entire Charging Station.
12    #[cfg_attr(feature = "serde", serde(rename = "evseId"))]
13    #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
14    pub evse_id: Option<i64>,
15    pub r#type: ResetEnum,
16}
17impl<CustomDataType> crate::Action for ResetRequest<CustomDataType> {
18    const ACTION: &'static str = "Reset";
19}
20#[cfg(feature = "validate")]
21impl<CustomDataType> crate::validate::Validate for ResetRequest<CustomDataType> {
22    fn validate(&self) -> Result<(), crate::validate::ValidationError> {
23        if let Some(value) = self.evse_id {
24            crate::validate::check_min_i64(value, 0i64)
25                .map_err(|error| error.in_field("evseId"))?;
26        }
27        crate::validate::Validate::validate(&self.r#type)
28            .map_err(|error| error.in_field("type"))?;
29        Ok(())
30    }
31}