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

When the slice passed to decode is not a valid length for the passed encoding.

The input lengths that are wrong for each encoding:

  • Base 64: when input.len() % 4 equals 1.
  • Base 32: when input.len() % 8 equals 1, 3 , or 6.
  • Base 16: when input.len() % 2 equals 1.

Example

Base 64

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

const DECODED: Result<[u8; 8], DecodeError> = decode(b"AAAAA", Config::B64);

match DECODED {
    Err(DecodeError::WrongInputLength(err)) => {
        assert_eq!(err.length(), 5);
        assert!(matches!(err.encoding(), Encoding::Base64{..}));
    }
    _ => unreachable!()
}

Implementations§

The length of the slice argument

The encoding that was attempted to decode from.

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.