use std::fmt;
use std::io;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum LazippyError {
#[error("not yet implemented")]
NotYetImplemented,
#[error("IO error: {0}")]
Io(#[from] io::Error),
#[error("LZMA backend error: {0}")]
Backend(String),
#[error("invalid header: {0}")]
InvalidHeader(String),
#[error("invalid properties byte: {0:#04x}")]
InvalidProperties(u8),
#[error("truncated LZMA stream")]
Truncated,
#[error("range coder error: {0}")]
RangeCoder(String),
}
impl LazippyError {
pub fn invalid_header<T: fmt::Display>(msg: T) -> Self {
LazippyError::InvalidHeader(msg.to_string())
}
pub fn range_coder<T: fmt::Display>(msg: T) -> Self {
LazippyError::RangeCoder(msg.to_string())
}
}
pub type LazippyResult<T> = Result<T, LazippyError>;