android_sparse/
result.rs

1//! Error handling with the `Result` type.
2
3use std::{fmt, io, result};
4
5/// Error type used for all errors produced by this crate.
6#[derive(Debug)]
7pub enum Error {
8    /// Error performing an I/O operation.
9    Io(io::Error),
10    /// Error during sparse file parsing.
11    Parse(String),
12}
13
14impl fmt::Display for Error {
15    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
16        match self {
17            Error::Io(err) => err.fmt(f),
18            Error::Parse(s) => f.write_str(s),
19        }
20    }
21}
22
23impl std::error::Error for Error {}
24
25impl From<io::Error> for Error {
26    fn from(err: io::Error) -> Self {
27        Error::Io(err)
28    }
29}
30
31/// Result type used for error handling in this crate.
32pub type Result<T> = result::Result<T, Error>;