Skip to main content

FrameError

Enum FrameError 

Source
#[non_exhaustive]
pub enum FrameError { NotAnArray, WrongArity { message_type: MessageTypeId, found: usize, expected: usize, }, UnknownMessageType { number: String, }, MessageTypeNotInVersion { message_type: MessageTypeId, version: Version, }, UnreadableMessageId { message_type: MessageTypeId, }, UnreadableAction { id: MessageId, }, UnreadableErrorCode { id: MessageId, }, }
Expand description

Why a text frame could not be turned into a Frame.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

NotAnArray

Not valid JSON, or not a JSON array with a numeric message type first.

§

WrongArity

The array has fewer elements than the message type requires.

Fields

§message_type: MessageTypeId

The message type that was read.

§found: usize

How many elements the array had.

§expected: usize

How many it needed.

§

UnknownMessageType

A message type number outside 2–6.

Ignored on every version: 1.6J §4.1.3, 2.x Part 4 §4.1.

Fields

§number: String

The raw JSON of the type element.

§

MessageTypeNotInVersion

A message type that exists in OCPP but not in the negotiated version (CALLRESULTERROR and SEND before 2.1).

Fields

§message_type: MessageTypeId

The message type that was read.

§version: Version

The negotiated version.

§

UnreadableMessageId

The MessageId element is missing, empty, or not a JSON string.

2.x answers with id "-1" (Part 4 §4.1.1); the message type decides which answer, so it is kept even though the id could not be read.

Fields

§message_type: MessageTypeId

The message type that was read.

§

UnreadableAction

The action element is not a JSON string.

Fields

§id: MessageId

The id to answer with.

§

UnreadableErrorCode

The error-code element is not a JSON string.

Fields

§id: MessageId

The id to answer with.

Implementations§

Source§

impl FrameError

Source

pub fn message_type(&self) -> Option<MessageTypeId>

The message type of the frame that failed to parse, when it got far enough to be read.

Source

pub fn reply(&self, version: Version) -> FrameReply

What the receiver must send back, per Part 4 §4.2.3.

Source

pub fn is_ignorable(&self) -> bool

Whether the specification says to silently ignore this frame rather than answer it.

True for a message type the version does not define, on every version: 1.6J §4.1.3 and 2.x Part 4 §4.1 (“it SHALL ignore the message”; 2.0.1 errata 2026-02 removed §4.4).

Source

pub fn error_code(&self) -> ErrorCode

The CALLERROR code to answer with, if the frame must be answered at all.

Source

pub fn reply_id(&self) -> MessageId

The id to use in the answer. "-1" when the incoming id could not be read.

Trait Implementations§

Source§

impl Clone for FrameError

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 FrameError

Source§

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

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

impl Display for FrameError

Source§

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

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

impl Eq for FrameError

Source§

impl Error for FrameError

Available on crate feature std only.
1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for FrameError

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 FrameError

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.