1use std::fmt::{self, Display};
2use std::io;
3
4pub(crate) type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Debug)]
8#[non_exhaustive]
9#[allow(missing_docs)]
10pub enum Error {
11 Nix(nix::Error),
12 Io(io::Error),
13}
14
15impl From<nix::Error> for Error {
16 fn from(err: nix::Error) -> Self {
17 Error::Nix(err)
18 }
19}
20
21impl From<io::Error> for Error {
22 fn from(err: io::Error) -> Self {
23 Error::Io(err)
24 }
25}
26
27impl Display for Error {
28 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
29 match self {
30 Error::Nix(err) => Display::fmt(err, formatter),
31 Error::Io(err) => Display::fmt(err, formatter),
32 }
33 }
34}
35
36impl std::error::Error for Error {
37 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
38 match self {
39 Error::Nix(err) => err.source(),
40 Error::Io(err) => err.source(),
41 }
42 }
43}