about summary refs log tree commit diff
path: root/src/libstd/io/pipe.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-01-29 16:33:57 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-02-03 09:32:33 -0800
commitece8a8f520697be50cbe543bebe065c5198dae4d (patch)
treefa1bf049d3b5d781c8c56e0d0491a655ece485a2 /src/libstd/io/pipe.rs
parentbe4fc638092bf896c5c6c0672136b83b71e491ee (diff)
std: Remove io::io_error
* All I/O now returns IoResult<T> = Result<T, IoError>
* All formatting traits now return fmt::Result = IoResult<()>
* The if_ok!() macro was added to libstd
Diffstat (limited to 'src/libstd/io/pipe.rs')
-rw-r--r--src/libstd/io/pipe.rs26
1 files changed, 4 insertions, 22 deletions
diff --git a/src/libstd/io/pipe.rs b/src/libstd/io/pipe.rs
index 9919d333f41..34d8bf96aa2 100644
--- a/src/libstd/io/pipe.rs
+++ b/src/libstd/io/pipe.rs
@@ -14,7 +14,7 @@
 //! enough so that pipes can be created to child processes.
 
 use prelude::*;
-use io::{io_error, EndOfFile};
+use io::IoResult;
 use libc;
 use rt::rtio::{RtioPipe, LocalIo};
 
@@ -42,7 +42,7 @@ impl PipeStream {
     ///
     /// If the pipe cannot be created, an error will be raised on the
     /// `io_error` condition.
-    pub fn open(fd: libc::c_int) -> Option<PipeStream> {
+    pub fn open(fd: libc::c_int) -> IoResult<PipeStream> {
         LocalIo::maybe_raise(|io| {
             io.pipe_open(fd).map(|obj| PipeStream { obj: obj })
         })
@@ -54,29 +54,11 @@ impl PipeStream {
 }
 
 impl Reader for PipeStream {
-    fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
-        match self.obj.read(buf) {
-            Ok(read) => Some(read),
-            Err(ioerr) => {
-                // EOF is indicated by returning None
-                if ioerr.kind != EndOfFile {
-                    io_error::cond.raise(ioerr);
-                }
-                return None;
-            }
-        }
-    }
+    fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.obj.read(buf) }
 }
 
 impl Writer for PipeStream {
-    fn write(&mut self, buf: &[u8]) {
-        match self.obj.write(buf) {
-            Ok(_) => (),
-            Err(ioerr) => {
-                io_error::cond.raise(ioerr);
-            }
-        }
-    }
+    fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.obj.write(buf) }
 }
 
 #[cfg(test)]