#[non_exhaustive]pub struct DecodeOptions {
pub unknown_enum_values: UnknownEnumValues,
pub unknown_fields: UnknownFields,
pub datetime: DateTimeLeniency,
pub numeric_strings: NumericStrings,
pub whole_floats: WholeFloats,
pub max_payload_size: usize,
pub max_repairs: usize,
}Expand description
Decoding policy. The strict default is exactly what the specification requires.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.unknown_enum_values: UnknownEnumValuesEnumeration values the schema does not define.
unknown_fields: UnknownFieldsMembers the schema does not define.
datetime: DateTimeLeniencydateTime spellings.
numeric_strings: NumericStringsNumbers sent as strings.
whole_floats: WholeFloatsWhole numbers written as 20000.0 where a draft-04 schema says integer.
max_payload_size: usizeUpper bound on one payload, in bytes — the fourth element of a CALL, not the
whole frame.
The frame is bounded earlier and elsewhere, at the socket, by
Csms::max_message_size_bytes;
this is the second line, and it is what a handler that decodes a payload of its own
gets for free. OCPP sets no limit of its own, and NotifyReport and
GetCompositeSchedule payloads can be large, so the default is generous.
max_repairs: usizeUpper bound on the number of leniency repairs applied to one payload.
Implementations§
Source§impl DecodeOptions
impl DecodeOptions
Sourcepub const fn pedantic() -> Self
pub const fn pedantic() -> Self
Everything the schemas require, plus rejection of undefined members.
Useful in tests and for a CSMS that wants to hold its fleet to the letter of
additionalProperties: false.
Sourcepub const fn lenient() -> Self
pub const fn lenient() -> Self
The knobs field devices actually need: undefined enum values and members are kept,
offset-less and space-separated timestamps are accepted, numeric strings are coerced,
and 20000.0 is accepted for a 1.6 integer.
Sourcepub const fn with_max_payload_size(self, bytes: usize) -> Self
pub const fn with_max_payload_size(self, bytes: usize) -> Self
Sets the maximum accepted payload size.
Sourcepub const fn with_unknown_enum_values(self, policy: UnknownEnumValues) -> Self
pub const fn with_unknown_enum_values(self, policy: UnknownEnumValues) -> Self
Sets how undefined enumeration values are treated.
Sourcepub const fn with_unknown_fields(self, policy: UnknownFields) -> Self
pub const fn with_unknown_fields(self, policy: UnknownFields) -> Self
Sets how undefined members are treated.
Sourcepub const fn with_datetime(self, policy: DateTimeLeniency) -> Self
pub const fn with_datetime(self, policy: DateTimeLeniency) -> Self
Sets which dateTime spellings are accepted.
Sourcepub const fn with_numeric_strings(self, policy: NumericStrings) -> Self
pub const fn with_numeric_strings(self, policy: NumericStrings) -> Self
Sets how numbers sent as strings are treated.
Sourcepub const fn with_whole_floats(self, policy: WholeFloats) -> Self
pub const fn with_whole_floats(self, policy: WholeFloats) -> Self
Sets how 20000.0 is treated where a draft-04 schema says integer.
Sourcepub const fn with_max_repairs(self, repairs: usize) -> Self
pub const fn with_max_repairs(self, repairs: usize) -> Self
Sets the maximum number of leniency repairs applied to one payload.