Enum ssz::DecodeError[][src]

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),
}
Expand description

Returned when SSZ decoding fails.

Variants

InvalidByteLength

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

Fields of InvalidByteLength

len: usizeexpected: usize
InvalidLengthPrefix

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

Fields of InvalidLengthPrefix

len: usizeexpected: 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 of OutOfBoundsByte

i: usize
OffsetIntoFixedPortion

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

Tuple Fields of OffsetIntoFixedPortion

0: usize
OffsetSkipsVariableBytes

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

Tuple Fields of OffsetSkipsVariableBytes

0: usize
OffsetsAreDecreasing

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

Tuple Fields of OffsetsAreDecreasing

0: usize
OffsetOutOfBounds

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

Tuple Fields of OffsetOutOfBounds

0: usize
InvalidListFixedBytesLen

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

Tuple Fields of InvalidListFixedBytesLen

0: usize
ZeroLengthItem

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

BytesInvalid

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

Tuple Fields of BytesInvalid

0: String

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.