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() % 4equals1. - Base 32: when
input.len() % 8equals1,3, or6. - Base 16: when
input.len() % 2equals1.
§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§
Trait Implementations§
Source§impl Debug for WrongInputLength
impl Debug for WrongInputLength
Source§impl PartialEq for WrongInputLength
impl PartialEq for WrongInputLength
impl StructuralPartialEq for WrongInputLength
Auto Trait Implementations§
impl Freeze for WrongInputLength
impl RefUnwindSafe for WrongInputLength
impl Send for WrongInputLength
impl Sync for WrongInputLength
impl Unpin for WrongInputLength
impl UnwindSafe for WrongInputLength
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more