1use core::fmt;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum Error {
8 UnexpectedEof,
10 Corrupt(&'static str),
12 Unsupported(&'static str),
14 Checksum(&'static str),
16 MissingBase,
18}
19
20impl fmt::Display for Error {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 match self {
23 Error::UnexpectedEof => write!(f, "unexpected end of input"),
24 Error::Corrupt(what) => write!(f, "corrupt data: {what}"),
25 Error::Unsupported(what) => write!(f, "unsupported: {what}"),
26 Error::Checksum(what) => write!(f, "checksum mismatch: {what}"),
27 Error::MissingBase => write!(f, "delta base object not found"),
28 }
29 }
30}
31
32impl core::error::Error for Error {}
33
34pub type Result<T> = core::result::Result<T, Error>;