pub struct ExcessBits { /* private fields */ }
Expand description

When the last byte in the slice passed to decode has excess set bits that aren’t copied to the return value.

Example

use const_base::{Config, DecodeError, decode};

assert_eq!(decode::<2>(b"ABA", Config::B64).unwrap(), [0u8, 16]);

// base 64 inputs of length 3 are 18 bits, which is 2 bytes and 2 excess bits.
// `ABC` is base64 for `[0b00000000, 0b00010000]` with excess `0b10` bits.
//
// Because the two unused bits at the end (which are `10`) include a set bit,
// it causes the `ExcessBits` error.
match decode::<2>(b"ABC", Config::B64) {
    Err(DecodeError::ExcessBits(err)) => {
        assert_eq!(err.last_byte(), b'C');
    }
    _ => unreachable!()
}

Implementations§

Unwraps a Result with this type as the error.

Panics with this error as the message.

Trait Implementations§

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 !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.