Skip to content

Commit

Permalink
Merge pull request #77 from inomotech-foss/master
Browse files Browse the repository at this point in the history
Add conversion to io::Error
  • Loading branch information
nastevens authored May 13, 2024
2 parents 6423dba + 2b87a33 commit 04cb2c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Changed

- Minimum supported Rust version updated to 1.65.0
- The crate's `Error` type can now be converted to a `std::io::Error` using `From` / `Into`.

## [0.6.1] - 2021-11-22

Expand Down
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 04cb2c0

Please sign in to comment.