Skip to content

Commit 5e41a49

Browse files
committed
Update nix to 0.25, hide nix from public API.
Hiding nix from the public API will allow to update it in the future without causing a breaking change.
1 parent efb1090 commit 5e41a49

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).
88

99
## [Unreleased]
1010

11+
- Hide nix from the public api such that it can be updated without resulting in a breaking change.
12+
- Updated nix to version `0.25`.
1113
- Updated nix to version `0.24`; only use the `ioctl` feature.
1214
- Use `File.read_exact` instead of `File.read` in `LinuxI2CDevice.read` so that the buffer is filled.
1315

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Provides API for safe access to Linux i2c device interface.
1818
libc = "0.2"
1919
bitflags = "1.3"
2020
byteorder = "1"
21-
nix = { version = "0.24", default-features = false, features = ["ioctl"] }
21+
nix = { version = "0.25", default-features = false, features = ["ioctl"] }
2222

2323
[dev-dependencies]
2424
docopt = "1"

src/linux.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,24 @@ pub struct LinuxI2CBus {
3333
devfile: File,
3434
}
3535

36+
/// Linux Errno error.
37+
#[derive(Debug)]
38+
pub struct Errno {
39+
nix: nix::Error,
40+
}
41+
3642
/// Linux I2C errors
3743
#[derive(Debug)]
3844
pub enum LinuxI2CError {
3945
/// OS error
40-
Nix(nix::Error),
46+
Errno(Errno),
4147
/// Input/output error
4248
Io(io::Error),
4349
}
4450

4551
impl From<nix::Error> for LinuxI2CError {
4652
fn from(e: nix::Error) -> Self {
47-
LinuxI2CError::Nix(e)
53+
LinuxI2CError::Errno(Errno { nix: e })
4854
}
4955
}
5056

@@ -58,15 +64,15 @@ impl From<LinuxI2CError> for io::Error {
5864
fn from(e: LinuxI2CError) -> io::Error {
5965
match e {
6066
LinuxI2CError::Io(e) => e,
61-
LinuxI2CError::Nix(e) => e.into(),
67+
LinuxI2CError::Errno(e) => e.nix.into(),
6268
}
6369
}
6470
}
6571

6672
impl fmt::Display for LinuxI2CError {
6773
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6874
match *self {
69-
LinuxI2CError::Nix(ref e) => fmt::Display::fmt(e, f),
75+
LinuxI2CError::Errno(ref e) => fmt::Display::fmt(&e.nix, f),
7076
LinuxI2CError::Io(ref e) => fmt::Display::fmt(e, f),
7177
}
7278
}
@@ -76,7 +82,7 @@ impl Error for LinuxI2CError {
7682
fn cause(&self) -> Option<&dyn Error> {
7783
match *self {
7884
LinuxI2CError::Io(ref e) => Some(e),
79-
LinuxI2CError::Nix(ref e) => Some(e),
85+
LinuxI2CError::Errno(ref e) => Some(&e.nix),
8086
}
8187
}
8288
}

0 commit comments

Comments
 (0)