pub struct NoCustomData;Expand description
Stands in for a customData object this deployment doesn’t read.
2.0.1 and 2.1 hang an optional customData field on nearly every object
in the specification – 151 structs in 2.1 alone – for vendor
extensions. Storing the spec’s shape inline costs 264 bytes at every
one of those nodes, and because structs nest by value that cost is
multiplied by the whole type graph rather than paid once.
So the field’s type is a parameter, and this is its default: a
zero-sized type, making Option<NoCustomData> one byte.
It is deliberately permissive, not empty. A peer may send
customData whenever it likes, so the default has to accept and discard
it – Option<()> would only accept null and would fail to parse any
message that actually carried an extension. That would turn opting out
of custom data into an interop bug.
The trade is that discarded data is not echoed back: re-serializing a
value parsed into NoCustomData writes {}, not what arrived. A
deployment that needs the contents names its own type instead:
use ocpp_types::v21::common::{Component, CustomData};
// The specification's own shape, opted into:
let with_spec_shape: Component<CustomData> = Component {
custom_data: None,
evse: None,
instance: None,
name: heapless::String::try_from("EVSE").unwrap(),
};Trait Implementations§
Source§impl Clone for NoCustomData
impl Clone for NoCustomData
Source§fn clone(&self) -> NoCustomData
fn clone(&self) -> NoCustomData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for NoCustomData
Source§impl Debug for NoCustomData
impl Debug for NoCustomData
Source§impl Default for NoCustomData
impl Default for NoCustomData
Source§fn default() -> NoCustomData
fn default() -> NoCustomData
Source§impl<'de> Deserialize<'de> for NoCustomData
Available on crate feature serde only.
impl<'de> Deserialize<'de> for NoCustomData
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for NoCustomData
Source§impl Hash for NoCustomData
impl Hash for NoCustomData
Source§impl Ord for NoCustomData
impl Ord for NoCustomData
Source§fn cmp(&self, other: &NoCustomData) -> Ordering
fn cmp(&self, other: &NoCustomData) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for NoCustomData
impl PartialEq for NoCustomData
Source§impl PartialOrd for NoCustomData
impl PartialOrd for NoCustomData
Source§impl Serialize for NoCustomData
Available on crate feature serde only.
impl Serialize for NoCustomData
serde only.