X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Fc_types%2Fmod.rs;fp=lightning-c-bindings%2Fsrc%2Fc_types%2Fmod.rs;h=220777636c1eca44f3c043292e4d6e61dd42515b;hp=3f8c900be02fd4d767d37eabddb21bcb859fa016;hb=7ca42fa60cd2d70628238f92be3cc6a89907568c;hpb=1830b38012c4b6674458b63f384bd549fcb52470 diff --git a/lightning-c-bindings/src/c_types/mod.rs b/lightning-c-bindings/src/c_types/mod.rs index 3f8c900..2207776 100644 --- a/lightning-c-bindings/src/c_types/mod.rs +++ b/lightning-c-bindings/src/c_types/mod.rs @@ -316,8 +316,8 @@ pub enum IOError { UnexpectedEof, } impl IOError { - pub(crate) fn from_rust(err: io::Error) -> Self { - match err.kind() { + pub(crate) fn from_rust_kind(err: io::ErrorKind) -> Self { + match err { io::ErrorKind::NotFound => IOError::NotFound, io::ErrorKind::PermissionDenied => IOError::PermissionDenied, io::ErrorKind::ConnectionRefused => IOError::ConnectionRefused, @@ -339,8 +339,11 @@ impl IOError { _ => IOError::Other, } } - pub(crate) fn to_rust(&self) -> io::Error { - io::Error::new(match self { + pub(crate) fn from_rust(err: io::Error) -> Self { + Self::from_rust_kind(err.kind()) + } + pub(crate) fn to_rust_kind(&self) -> io::ErrorKind { + match self { IOError::NotFound => io::ErrorKind::NotFound, IOError::PermissionDenied => io::ErrorKind::PermissionDenied, IOError::ConnectionRefused => io::ErrorKind::ConnectionRefused, @@ -359,7 +362,10 @@ impl IOError { IOError::Interrupted => io::ErrorKind::Interrupted, IOError::Other => io::ErrorKind::Other, IOError::UnexpectedEof => io::ErrorKind::UnexpectedEof, - }, "") + } + } + pub(crate) fn to_rust(&self) -> io::Error { + io::Error::new(self.to_rust_kind(), "") } }