refactor errno_from_ioerror

This commit is contained in:
Marcin Mielniczuk
2019-09-08 09:38:03 +02:00
committed by Jakub Konka
parent ae836df42d
commit c5339d01cf
2 changed files with 10 additions and 11 deletions

View File

@@ -1,5 +1,4 @@
use crate::host; use crate::host;
use crate::sys::errno_from_ioerror;
use failure::Fail; use failure::Fail;
use std::convert::Infallible; use std::convert::Infallible;
use std::fmt; use std::fmt;
@@ -254,3 +253,13 @@ impl fmt::Display for Error {
} }
} }
} }
fn errno_from_ioerror(e: &std::io::Error) -> host::__wasi_errno_t {
match e.raw_os_error() {
Some(code) => crate::sys::errno_from_host(code),
None => {
log::debug!("Inconvertible OS error: {}", e);
host::__WASI_EIO
}
}
}

View File

@@ -22,13 +22,3 @@ cfg_if! {
compile_error!("wasi-common doesn't compile for this platform yet"); compile_error!("wasi-common doesn't compile for this platform yet");
} }
} }
pub(crate) fn errno_from_ioerror(e: &std::io::Error) -> host::__wasi_errno_t {
match e.raw_os_error() {
Some(code) => errno_from_host(code),
None => {
log::debug!("Inconvertible OS error: {}", e);
host::__WASI_EIO
}
}
}