Enum ssz::DecodeError

source ·
pub enum DecodeError {
    InvalidByteLength {
        len: usize,
        expected: usize,
    },
    InvalidLengthPrefix {
        len: usize,
        expected: usize,
    },
    OutOfBoundsByte {
        i: usize,
    },
    OffsetIntoFixedPortion(usize),
    OffsetSkipsVariableBytes(usize),
    OffsetsAreDecreasing(usize),
    OffsetOutOfBounds(usize),
    InvalidListFixedBytesLen(usize),
    ZeroLengthItem,
    BytesInvalid(String),
    UnionSelectorInvalid(u8),
    NoMatchingVariant,
}
Expand description

Returned when SSZ decoding fails.

Variants§

§

InvalidByteLength

The bytes supplied were too short to be decoded into the specified type.

Fields

§len: usize
§expected: usize
§

InvalidLengthPrefix

The given bytes were too short to be read as a length prefix.

Fields

§len: usize
§expected: usize
§

OutOfBoundsByte

A length offset pointed to a byte that was out-of-bounds (OOB).

A bytes may be OOB for the following reasons:

  • It is >= bytes.len().
  • When decoding variable length items, the 1st offset points “backwards” into the fixed length items (i.e., length[0] < BYTES_PER_LENGTH_OFFSET).
  • When decoding variable-length items, the n’th offset was less than the n-1’th offset.

Fields

§

OffsetIntoFixedPortion(usize)

An offset points “backwards” into the fixed-bytes portion of the message, essentially double-decoding bytes that will also be decoded as fixed-length.

https://notes.ethereum.org/ruKvDXl6QOW3gnqVYb8ezA?view#1-Offset-into-fixed-portion

§

OffsetSkipsVariableBytes(usize)

The first offset does not point to the byte that follows the fixed byte portion, essentially skipping a variable-length byte.

https://notes.ethereum.org/ruKvDXl6QOW3gnqVYb8ezA?view#2-Skip-first-variable-byte

§

OffsetsAreDecreasing(usize)

An offset points to bytes prior to the previous offset. Depending on how you look at it, this either double-decodes bytes or makes the first offset a negative-length.

https://notes.ethereum.org/ruKvDXl6QOW3gnqVYb8ezA?view#3-Offsets-are-decreasing

§

OffsetOutOfBounds(usize)

An offset references byte indices that do not exist in the source bytes.

https://notes.ethereum.org/ruKvDXl6QOW3gnqVYb8ezA?view#4-Offsets-are-out-of-bounds

§

InvalidListFixedBytesLen(usize)

A variable-length list does not have a fixed portion that is cleanly divisible by BYTES_PER_LENGTH_OFFSET.

§

ZeroLengthItem

Some item has a ssz_fixed_len of zero. This is illegal.

§

BytesInvalid(String)

The given bytes were invalid for some application-level reason.

§

UnionSelectorInvalid(u8)

The given union selector is out of bounds.

§

NoMatchingVariant

The given bytes could not be successfully decoded into any variant of the transparent enum.

Trait Implementations§

source§

impl Clone for DecodeError

source§

fn clone(&self) -> DecodeError

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for DecodeError

source§

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

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

impl PartialEq for DecodeError

source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for DecodeError

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
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 = 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.