Skip to main content

Error

Enum Error 

Source
pub enum Error {
    Io {
        message: String,
    },
    Invalid {
        message: String,
    },
    UnexpectedToken {
        expected: Vec<&'static str>,
        got: &'static str,
    },
    UnexpectedSymbol {
        expected: Vec<&'static str>,
        got: String,
    },
    ArgCountMismatch {
        expected: u64,
        got: u64,
    },
    Deserialize {
        path: String,
        expected: &'static str,
        got: String,
    },
}
Expand description

Errors returned by [to_wxf][crate::to_wxf] / [from_wxf][crate::from_wxf] and every ToWXF / FromWXF impl.

Variants§

§

Io

An underlying std::io::Error from a writer, flattened to its message.

Fields

§message: String

Display text of the underlying I/O error.

§

Invalid

Malformed input with no further structured data worth surfacing: bad/short header, wrong version/separator, truncated or over-long varint, unexpected EOF, byte-count overflow, unknown token/element byte, invalid UTF-8, an empty enum, a NaN real, an unparseable symbol name, or an unsupported packed-array element type. The message says which.

Fields

§message: String

Human-readable description of what was malformed.

§

UnexpectedToken

Got a token that isn’t one of the accepted set for this position. An empty expected means “any value token except the one we got” (e.g. a Rule where a value was required).

Fields

§expected: Vec<&'static str>

Token names that would have been accepted.

§got: &'static str

The token name actually read.

§

UnexpectedSymbol

Got a Symbol whose name isn’t one of the accepted set (e.g. True/False, or an Option/Result variant name).

Fields

§expected: Vec<&'static str>

Symbol / variant names that would have been accepted.

§got: String

The name actually read.

§

ArgCountMismatch

A Function’s argument count didn’t match what the caller expected.

Fields

§expected: u64

Arguments the caller expected.

§got: u64

Arguments actually present.

§

Deserialize

Type mismatch during typed deserialization via FromWXF. Threaded with a dotted field path by the derive (e.g. "Frame.payload").

Fields

§path: String

Dotted field accessor, e.g. "Frame.payload".

§expected: &'static str

Description of the expected wire shape.

§got: String

Description of the actual wire shape encountered.

Implementations§

Source§

impl Error

Source

pub fn invalid(message: String) -> Self

Build an Error::Invalid from a message — for malformed input that has no further structured data worth a dedicated variant.

Source

pub fn unexpected_token(expected: &[&'static str], got: ExpressionEnum) -> Self

Build an Error::UnexpectedToken from the accepted token names and the token actually read. An empty expected slice means “any token but this”.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.