Skip to content

Commit

Permalink
Add conversion to io::Error
Browse files Browse the repository at this point in the history
  • Loading branch information
scootermon committed May 1, 2024
1 parent 709bd24 commit 0ddfe98
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,14 @@ impl convert::From<nix::Error> for Error {
Error::Io(e.into())
}
}

impl convert::From<Error> for io::Error {
fn from(e: Error) -> io::Error {
match e {
Error::Io(err) => err,
Error::Unexpected(err) => io::Error::new(io::ErrorKind::Unsupported, err),
Error::InvalidPath(err) => io::Error::new(io::ErrorKind::InvalidInput, err),
Error::Unsupported(err) => io::Error::new(io::ErrorKind::InvalidData, err),
}
}
}

0 comments on commit 0ddfe98

Please sign in to comment.