"std::time::Duration"|"core::time::Duration" => Some("u64"),
"std::time::SystemTime" => Some("u64"),
- "std::io::Error"|"lightning::io::Error" => Some("crate::c_types::IOError"),
+ "std::io::Error"|"lightning::io::Error"|"lightning::io::ErrorKind" => Some("crate::c_types::IOError"),
"core::fmt::Arguments" if is_ref => Some("crate::c_types::Str"),
"core::convert::Infallible" => Some("crate::c_types::NotConstructable"),
"str" if is_ref => Some(""),
"alloc::string::String"|"String" => Some(""),
- "std::io::Error"|"lightning::io::Error" => Some(""),
+ "std::io::Error"|"lightning::io::Error"|"lightning::io::ErrorKind" => Some(""),
// Note that we'll panic for String if is_ref, as we only have non-owned memory, we
// cannot create a &String.
"str" if is_ref => Some(".into_str()"),
"alloc::string::String"|"String" => Some(".into_string()"),
"std::io::Error"|"lightning::io::Error" => Some(".to_rust()"),
+ "lightning::io::ErrorKind" => Some(".to_rust_kind()"),
"core::convert::Infallible" => Some("\")"),
"std::time::Duration"|"core::time::Duration" => Some(""),
"std::time::SystemTime" => Some(""),
"std::io::Error"|"lightning::io::Error" => Some("crate::c_types::IOError::from_rust("),
+ "lightning::io::ErrorKind" => Some("crate::c_types::IOError::from_rust_kind("),
"core::fmt::Arguments" => Some("alloc::format!(\"{}\", "),
"core::convert::Infallible" => Some("panic!(\"Cannot construct an Infallible: "),
"std::time::Duration"|"core::time::Duration" => Some(".as_secs()"),
"std::time::SystemTime" => Some(".duration_since(::std::time::SystemTime::UNIX_EPOCH).expect(\"Times must be post-1970\").as_secs()"),
- "std::io::Error"|"lightning::io::Error" => Some(")"),
+ "std::io::Error"|"lightning::io::Error"|"lightning::io::ErrorKind" => Some(")"),
"core::fmt::Arguments" => Some(").into()"),
"core::convert::Infallible" => Some("\")"),
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,
_ => 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,
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(), "")
}
}