1use std::fmt::Display;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Debug)]
6pub enum Error {
7 NixError(nix::Error),
8 IoError(std::io::Error),
9}
10
11impl Display for Error {
12 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13 match self {
14 Self::NixError(err) => write!(f, "{err}"),
15 Self::IoError(err) => write!(f, "{err}"),
16 }
17 }
18}
19
20impl std::error::Error for Error {}
21
22impl From<std::io::Error> for Error {
23 fn from(err: std::io::Error) -> Self {
24 Self::IoError(err)
25 }
26}
27
28impl From<nix::Error> for Error {
29 fn from(err: nix::Error) -> Self {
30 Self::NixError(err)
31 }
32}