#[non_exhaustive]pub enum Error {
Show 14 variants
BwtFailed,
ChecksumMismatch,
CorruptStageData,
InvalidMagic,
TruncatedHeader,
InvalidHeader,
TruncatedData,
BlockTooLarge,
BufferTooSmall,
OutputSizeMismatch,
OutOfMemory,
InvalidBlockSize,
ThreadPoolFailed,
Io(Error),
}Expand description
Every failure mode of the bzip3 port.
Ten variants keep the C reference codes. Four variants have
no reference code. OutOfMemory, InvalidBlockSize, and
ThreadPoolFailed split the old reference init error. Io is
produced only by the streaming wrappers when a read or write fails.
Some reference codes map to more than one variant. Use Error::code
to get the reference code.
The enum is #[non_exhaustive]. A match needs a wildcard arm.
§Examples
use bzip3_rs::decompress;
use bzip3_rs::error::Error;
match decompress(&[0_u8; 13]) {
Ok(_) => unreachable!("zero bytes are not a frame"),
Err(Error::InvalidMagic) => {}
Err(other) => panic!("unexpected error: {other}"),
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
BwtFailed
Burrows-Wheeler transform failed (reference code -2).
ChecksumMismatch
Checksum of the decoded block does not match (reference code -3).
CorruptStageData
RLE or LZP data is corrupt (reference code -3).
InvalidMagic
Magic number is wrong (reference code -4).
TruncatedHeader
Header is shorter than its fixed size (reference code -4).
InvalidHeader
Header field is out of range or inconsistent (reference code -4).
TruncatedData
Data ends before the end of a payload (reference code -5).
BlockTooLarge
Block too large (reference code -6).
BufferTooSmall
Payload is larger than the decode buffer (reference code -8).
OutputSizeMismatch
Output buffer length is not the original block size (reference code -8).
OutOfMemory
Working memory allocation failed. No reference code.
InvalidBlockSize
Block size outside the valid range. No reference code.
ThreadPoolFailed
Private thread pool build failed. No reference code.
Io(Error)
Read or write failure inside a streaming wrapper. No reference code.
Implementations§
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more