Enum boba::DecodeError
source · pub enum DecodeError {
ChecksumMismatch,
Corrupted,
ExpectedConsonant,
ExpectedVowel,
InvalidByte(usize),
MalformedHeader,
MalformedTrailer,
}
Expand description
Decoding errors from boba::decode
.
decode
will return a DecodeError
if:
- The input is not an ASCII string.
- The input contains an ASCII character outside of the Bubble Babble encoding alphabet.
- The input does not start with a leading
x
. - The input does not end with a trailing
x
. - The decoded result does not checksum properly.
§Examples
assert_eq!(boba::decode("x💎🦀x"), Err(DecodeError::InvalidByte(1)));
assert_eq!(boba::decode("x789x"), Err(DecodeError::InvalidByte(1)));
assert_eq!(boba::decode("yx"), Err(DecodeError::MalformedHeader));
assert_eq!(boba::decode("xy"), Err(DecodeError::MalformedTrailer));
assert_eq!(boba::decode(""), Err(DecodeError::Corrupted));
assert_eq!(boba::decode("z"), Err(DecodeError::Corrupted));
assert_eq!(boba::decode("xx"), Err(DecodeError::Corrupted));
Variants§
ChecksumMismatch
Checksum mismatch when decoding input.
Corrupted
Corrupted input caused a decoding failure.
ExpectedConsonant
Expected to process a consonant from the encoding alphabet, but got something else.
ExpectedVowel
Expected to process a vowel from the encoding alphabet, but got something else.
InvalidByte(usize)
Input contained a byte not in the encoding alphabet at this position.
MalformedHeader
Input was missing a leading x
header.
MalformedTrailer
Input was missing a final x
trailer.
Trait Implementations§
source§impl Clone for DecodeError
impl Clone for DecodeError
source§fn clone(&self) -> DecodeError
fn clone(&self) -> DecodeError
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for DecodeError
impl Debug for DecodeError
source§impl Display for DecodeError
impl Display for DecodeError
source§impl Error for DecodeError
impl Error for DecodeError
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl Hash for DecodeError
impl Hash for DecodeError
source§impl Ord for DecodeError
impl Ord for DecodeError
source§fn cmp(&self, other: &DecodeError) -> Ordering
fn cmp(&self, other: &DecodeError) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for DecodeError
impl PartialEq for DecodeError
source§fn eq(&self, other: &DecodeError) -> bool
fn eq(&self, other: &DecodeError) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for DecodeError
impl PartialOrd for DecodeError
source§fn partial_cmp(&self, other: &DecodeError) -> Option<Ordering>
fn partial_cmp(&self, other: &DecodeError) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for DecodeError
impl Eq for DecodeError
impl StructuralPartialEq for DecodeError
Auto Trait Implementations§
impl Freeze for DecodeError
impl RefUnwindSafe for DecodeError
impl Send for DecodeError
impl Sync for DecodeError
impl Unpin for DecodeError
impl UnwindSafe for DecodeError
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