Skip to main content

DecodeOptions

Struct DecodeOptions 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§unknown_enum_values: UnknownEnumValues

Enumeration values the schema does not define.

§unknown_fields: UnknownFields

Members the schema does not define.

§datetime: DateTimeLeniency

dateTime spellings.

§numeric_strings: NumericStrings

Numbers sent as strings.

§whole_floats: WholeFloats

Whole numbers written as 20000.0 where a draft-04 schema says integer.

§max_payload_size: usize

Upper 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: usize

Upper bound on the number of leniency repairs applied to one payload.

Implementations§

Source§

impl DecodeOptions

Source

pub const fn strict() -> Self

Exactly what the specification requires. The default.

Source

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.

Source

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.

Source

pub const fn with_max_payload_size(self, bytes: usize) -> Self

Sets the maximum accepted payload size.

Source

pub const fn with_unknown_enum_values(self, policy: UnknownEnumValues) -> Self

Sets how undefined enumeration values are treated.

Source

pub const fn with_unknown_fields(self, policy: UnknownFields) -> Self

Sets how undefined members are treated.

Source

pub const fn with_datetime(self, policy: DateTimeLeniency) -> Self

Sets which dateTime spellings are accepted.

Source

pub const fn with_numeric_strings(self, policy: NumericStrings) -> Self

Sets how numbers sent as strings are treated.

Source

pub const fn with_whole_floats(self, policy: WholeFloats) -> Self

Sets how 20000.0 is treated where a draft-04 schema says integer.

Source

pub const fn with_max_repairs(self, repairs: usize) -> Self

Sets the maximum number of leniency repairs applied to one payload.

Trait Implementations§

Source§

impl Clone for DecodeOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DecodeOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DecodeOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for DecodeOptions

Source§

impl PartialEq for DecodeOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DecodeOptions

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.