use std::fmt;
pub type Result<T> = std::result::Result<T, GDeltaError>;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum GDeltaError {
InvalidDelta(String),
UnexpectedEndOfData,
SizeMismatch {
expected: usize,
actual: usize,
},
BufferError(String),
}
impl fmt::Display for GDeltaError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
GDeltaError::InvalidDelta(msg) => write!(f, "Invalid delta: {msg}"),
GDeltaError::UnexpectedEndOfData => write!(f, "Unexpected end of data"),
GDeltaError::SizeMismatch { expected, actual } => {
write!(
f,
"Size mismatch: expected {expected} bytes, got {actual} bytes"
)
}
GDeltaError::BufferError(msg) => write!(f, "Buffer error: {msg}"),
}
}
}
impl std::error::Error for GDeltaError {}