Skip to main content

DecodeError

Enum DecodeError 

Source
pub enum DecodeError<SourceError, DestinationError> {
    Source(SourceError),
    Destination(DestinationError),
    UnexpectedSourceEof,
    EmptyFrame,
    InvalidFrame(DecodeProgress),
}
Expand description

A failure to decode a frame.

Generic parameters preserve the source and destination error types. Match their variants to inspect them: the current core::error::Error implementation does not forward source().

Errors do not roll back partial output. Only InvalidFrame carries progress information.

Implementations such as Clone, Copy, serialization, and compact formatting depend on the corresponding traits being implemented by both generic error parameters.

Error formatting is diagnostic output, not a stable serialization format.

Variants§

§

Source(SourceError)

Reading the source failed.

Never returned by the sync module, which reads from memory.

§

Destination(DestinationError)

The destination cannot hold the next decoded byte.

sync::decode_to_slice reports SeekableError::OutOfBounds here. The destination may be partially overwritten.

§

UnexpectedSourceEof

The input ended before the current COBS block was complete.

§

EmptyFrame

One-shot decoding reached EOF without starting an encoded frame.

Empty input and zero padding alone produce this error. A valid encoding of an empty payload, such as [1], does not.

§

InvalidFrame(DecodeProgress)

A zero delimiter arrived before the current COBS block had enough data.

Progress includes the delimiter and has frame_len: None. Partial output already written to the destination is not removed.

The next frame starts at source[progress.consumed as usize..].

Trait Implementations§

Source§

impl<SourceError: Clone, DestinationError: Clone> Clone for DecodeError<SourceError, DestinationError>

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<SourceError: Copy, DestinationError: Copy> Copy for DecodeError<SourceError, DestinationError>

Source§

impl<SourceError: Debug, DestinationError: Debug> Debug for DecodeError<SourceError, DestinationError>

Source§

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

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

impl<'de, SourceError, DestinationError> Deserialize<'de> for DecodeError<SourceError, DestinationError>
where SourceError: Deserialize<'de>, DestinationError: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<S, D> Display for DecodeError<S, D>
where S: Error, D: Error,

Source§

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

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

impl<SourceError: Eq, DestinationError: Eq> Eq for DecodeError<SourceError, DestinationError>

Source§

impl<S: Error, D: Error> Error for DecodeError<S, D>

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<S, D> Format for DecodeError<S, D>
where D: Format, S: Format,

Available on crate feature defmt only.
Source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.
Source§

impl<SourceError: Hash, DestinationError: Hash> Hash for DecodeError<SourceError, DestinationError>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<SourceError: PartialEq, DestinationError: PartialEq> PartialEq for DecodeError<SourceError, DestinationError>

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<SourceError, DestinationError> Serialize for DecodeError<SourceError, DestinationError>
where SourceError: Serialize, DestinationError: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<SourceError: PartialEq, DestinationError: PartialEq> StructuralPartialEq for DecodeError<SourceError, DestinationError>

Auto Trait Implementations§

§

impl<SourceError, DestinationError> Freeze for DecodeError<SourceError, DestinationError>
where SourceError: Freeze, DestinationError: Freeze,

§

impl<SourceError, DestinationError> RefUnwindSafe for DecodeError<SourceError, DestinationError>
where SourceError: RefUnwindSafe, DestinationError: RefUnwindSafe,

§

impl<SourceError, DestinationError> Send for DecodeError<SourceError, DestinationError>
where SourceError: Send, DestinationError: Send,

§

impl<SourceError, DestinationError> Sync for DecodeError<SourceError, DestinationError>
where SourceError: Sync, DestinationError: Sync,

§

impl<SourceError, DestinationError> Unpin for DecodeError<SourceError, DestinationError>
where SourceError: Unpin, DestinationError: Unpin,

§

impl<SourceError, DestinationError> UnsafeUnpin for DecodeError<SourceError, DestinationError>
where SourceError: UnsafeUnpin, DestinationError: UnsafeUnpin,

§

impl<SourceError, DestinationError> UnwindSafe for DecodeError<SourceError, DestinationError>
where SourceError: UnwindSafe, DestinationError: UnwindSafe,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

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.