1use core::fmt;
2
3#[derive(Debug)]
4pub enum ZError {
5 InvalidLength(usize, usize),
6 OutOfBounds(usize, usize),
7 InvalidUtf8,
8 Custom(&'static str),
9}
10
11impl fmt::Display for ZError {
12 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13 match self {
14 ZError::InvalidLength(expected, actual) => {
15 write!(f, "Invalid length: expected {}, got {}", expected, actual)
16 }
17 ZError::OutOfBounds(idx, len) => {
18 write!(f, "Index out of bounds: index {}, len {}", idx, len)
19 }
20 ZError::InvalidUtf8 => write!(f, "Invalid UTF-8 sequence"),
21 ZError::Custom(msg) => write!(f, "Error: {}", msg),
22 }
23 }
24}
25
26