Skip to content

Commit

Permalink
Update nix to ~0.22
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkna committed Oct 13, 2021
1 parent 2023387 commit 45097b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion battery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ winapi = { version ="~0.3", features = ["impl-default", "devguid", "winbase", "i

[target.'cfg(any(target_os = "dragonfly", target_os = "freebsd"))'.dependencies]
libc = "~0.2"
nix = "~0.19"
nix = "~0.22"

[dev-dependencies]
tempfile = "^3.0"
Expand Down
22 changes: 4 additions & 18 deletions battery/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,10 @@ mod nix_impl {
use super::Error;

impl From<nix::Error> for Error {
fn from(e: nix::Error) -> Self {
match e {
nix::Error::Sys(errno) => Error {
source: io::Error::from_raw_os_error(errno as i32),
description: Some(errno.desc().into()),
},
nix::Error::InvalidPath => Error {
source: io::Error::new(io::ErrorKind::InvalidInput, e),
description: Some("Invalid path".into()),
},
nix::Error::InvalidUtf8 => Error {
source: io::Error::new(io::ErrorKind::InvalidData, e),
description: Some("Invalid UTF-8 string".into()),
},
nix::Error::UnsupportedOperation => Error {
source: io::Error::new(io::ErrorKind::Other, e),
description: Some("Unsupported operation".into()),
},
fn from(errno: nix::Error) -> Self {
Error {
source: io::Error::from_raw_os_error(errno as i32),
description: Some(errno.desc().into()),
}
}
}
Expand Down

0 comments on commit 45097b4

Please sign in to comment.