@@ -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 ) ]
3844pub enum LinuxI2CError {
3945 /// OS error
40- Nix ( nix :: Error ) ,
46+ Errno ( Errno ) ,
4147 /// Input/output error
4248 Io ( io:: Error ) ,
4349}
4450
4551impl 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
6672impl 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