From 0900cfbac1a7e4b432425af97b68cfee68b4dd4c Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 23 Sep 2014 21:37:17 -0500 Subject: [PATCH] Losslessly convert from `rtio::IoError` to `io::IoError` Closes #5 --- src/lib.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2570cd3..72cb499 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,7 @@ extern crate quickcheck; extern crate quickcheck_macros; use native::io::file::FileDesc; -use std::io::{FileAccess, IoError, IoResult, OtherIoError, Read, ReadWrite, Write}; +use std::io::{FileAccess, IoError, IoResult, Read, ReadWrite, Write}; use termios::{FAILURE, Termios, SUCCESS}; @@ -257,12 +257,7 @@ impl SerialPort { impl Reader for SerialPort { fn read(&mut self, buf: &mut [u8]) -> IoResult { match self.file.inner_read(buf) { - Err(err) => Err(IoError { - // FIXME How to convert rtio::IoError to io::IoError? - desc: "", - detail: err.detail, - kind: OtherIoError, - }), + Err(err) => Err(IoError::from_errno(err.code, true)), Ok(ret) => Ok(ret), } } @@ -271,12 +266,7 @@ impl Reader for SerialPort { impl Writer for SerialPort { fn write(&mut self, buf: &[u8]) -> IoResult<()> { match self.file.inner_write(buf) { - Err(err) => Err(IoError { - // FIXME How to convert rtio::IoError to io::IoError? - desc: "", - detail: err.detail, - kind: OtherIoError, - }), + Err(err) => Err(IoError::from_errno(err.code, true)), Ok(_) => Ok(()), } }