impl From for EmscriptenVfsError

This commit is contained in:
Mackenzie Clark 2019-03-27 16:14:29 -07:00
parent 074013648e
commit 18eae44577

View File

@ -102,9 +102,7 @@ impl EmscriptenVfs {
match self.fd_map.get(&fd) { match self.fd_map.get(&fd) {
Some(FileHandle::Vf(file)) => { Some(FileHandle::Vf(file)) => {
let mut mut_ref = RefCell::borrow_mut(file); let mut mut_ref = RefCell::borrow_mut(file);
mut_ref mut_ref.write_file(buf_slice, 0).into()
.write_file(buf_slice, 0)
.map_err(|e| EmscriptenVfsError::Io(e))
} }
Some(FileHandle::Socket(host_fd)) => unsafe { Some(FileHandle::Socket(host_fd)) => unsafe {
let result = libc::write(*host_fd, buf_slice.as_ptr() as _, count as _); let result = libc::write(*host_fd, buf_slice.as_ptr() as _, count as _);
@ -149,3 +147,9 @@ pub enum EmscriptenVfsError {
Errno(errno::Errno), Errno(errno::Errno),
FileSystemError, FileSystemError,
} }
impl From<io::Error> for EmscriptenVfsError {
fn from(io_error: io::Error) -> Self {
EmscriptenVfsError::Io(io_error)
}
}