diff --git a/src/librustuv/uvio.rs b/src/librustuv/uvio.rs index 8ea3e2ddcc6..37910cef60e 100644 --- a/src/librustuv/uvio.rs +++ b/src/librustuv/uvio.rs @@ -1653,9 +1653,6 @@ impl RtioFileStream for UvFileStream { let self_ = unsafe { cast::transmute::<&UvFileStream, &mut UvFileStream>(self) }; self_.seek_common(0, SEEK_CUR) } - fn flush(&mut self) -> Result<(), IoError> { - Ok(()) - } } pub struct UvProcess { diff --git a/src/libstd/rt/io/buffered.rs b/src/libstd/rt/io/buffered.rs index 47c8dbd35c6..fc6d43f551a 100644 --- a/src/libstd/rt/io/buffered.rs +++ b/src/libstd/rt/io/buffered.rs @@ -418,7 +418,6 @@ mod test { impl rt::io::Writer for S { fn write(&mut self, _: &[u8]) {} - fn flush(&mut self) {} } impl rt::io::Reader for S { diff --git a/src/libstd/rt/io/comm_adapters.rs b/src/libstd/rt/io/comm_adapters.rs index 06424fee8bc..98dbec27fb9 100644 --- a/src/libstd/rt/io/comm_adapters.rs +++ b/src/libstd/rt/io/comm_adapters.rs @@ -32,8 +32,6 @@ impl> ChanWriter { impl> Writer for ChanWriter { fn write(&mut self, _buf: &[u8]) { fail!() } - - fn flush(&mut self) { fail!() } } struct ReaderPort; diff --git a/src/libstd/rt/io/file.rs b/src/libstd/rt/io/file.rs index d035e2f457c..99a4a709504 100644 --- a/src/libstd/rt/io/file.rs +++ b/src/libstd/rt/io/file.rs @@ -383,15 +383,6 @@ impl Writer for FileStream { } } } - - fn flush(&mut self) { - match self.fd.flush() { - Ok(_) => (), - Err(ioerr) => { - io_error::cond.raise(ioerr); - } - } - } } /// a `std::rt::io:Seek` trait impl for file I/O. diff --git a/src/libstd/rt/io/mem.rs b/src/libstd/rt/io/mem.rs index 0ec37cd3c07..6803637d7cb 100644 --- a/src/libstd/rt/io/mem.rs +++ b/src/libstd/rt/io/mem.rs @@ -62,8 +62,6 @@ impl Writer for MemWriter { // Bump us forward self.pos += buf.len(); } - - fn flush(&mut self) { /* no-op */ } } impl Seek for MemWriter { diff --git a/src/libstd/rt/io/mock.rs b/src/libstd/rt/io/mock.rs index 44709c7b7b6..a0fd6846ce9 100644 --- a/src/libstd/rt/io/mock.rs +++ b/src/libstd/rt/io/mock.rs @@ -32,19 +32,16 @@ impl Reader for MockReader { pub struct MockWriter { priv write: ~fn(buf: &[u8]), - priv flush: ~fn() } impl MockWriter { pub fn new() -> MockWriter { MockWriter { write: |_| (), - flush: || () } } } impl Writer for MockWriter { fn write(&mut self, buf: &[u8]) { (self.write)(buf) } - fn flush(&mut self) { (self.flush)() } } diff --git a/src/libstd/rt/io/mod.rs b/src/libstd/rt/io/mod.rs index 5eba3b2b801..1fd3bf1f238 100644 --- a/src/libstd/rt/io/mod.rs +++ b/src/libstd/rt/io/mod.rs @@ -810,8 +810,12 @@ pub trait Writer { /// Raises the `io_error` condition on error fn write(&mut self, buf: &[u8]); - /// Flush output - fn flush(&mut self); + /// Flush this output stream, ensuring that all intermediately buffered + /// contents reach their destination. + /// + /// This is by default a no-op and implementors of the `Writer` trait should + /// decide whether their stream needs to be buffered or not. + fn flush(&mut self) {} /// Write the result of passing n through `int::to_str_bytes`. fn write_int(&mut self, n: int) { diff --git a/src/libstd/rt/io/native/file.rs b/src/libstd/rt/io/native/file.rs index ba819df071a..9f9e7dcee9f 100644 --- a/src/libstd/rt/io/native/file.rs +++ b/src/libstd/rt/io/native/file.rs @@ -132,8 +132,6 @@ impl Writer for FileDesc { raise_error(); } } - - fn flush(&mut self) {} } impl Drop for FileDesc { diff --git a/src/libstd/rt/io/net/tcp.rs b/src/libstd/rt/io/net/tcp.rs index fb7c6766fd8..493ed6aba87 100644 --- a/src/libstd/rt/io/net/tcp.rs +++ b/src/libstd/rt/io/net/tcp.rs @@ -84,8 +84,6 @@ impl Writer for TcpStream { Err(ioerr) => io_error::cond.raise(ioerr), } } - - fn flush(&mut self) { /* no-op */ } } pub struct TcpListener { diff --git a/src/libstd/rt/io/net/udp.rs b/src/libstd/rt/io/net/udp.rs index 2e4ae95d98e..f9cf8f5f9ae 100644 --- a/src/libstd/rt/io/net/udp.rs +++ b/src/libstd/rt/io/net/udp.rs @@ -100,8 +100,6 @@ impl Writer for UdpStream { sock.sendto(buf, self.connectedTo); } } - - fn flush(&mut self) { fail!() } } #[cfg(test)] diff --git a/src/libstd/rt/io/net/unix.rs b/src/libstd/rt/io/net/unix.rs index d9bdb73066d..f30423812ba 100644 --- a/src/libstd/rt/io/net/unix.rs +++ b/src/libstd/rt/io/net/unix.rs @@ -78,7 +78,6 @@ impl Reader for UnixStream { impl Writer for UnixStream { fn write(&mut self, buf: &[u8]) { self.obj.write(buf) } - fn flush(&mut self) { self.obj.flush() } } pub struct UnixListener { diff --git a/src/libstd/rt/io/pipe.rs b/src/libstd/rt/io/pipe.rs index ec9a4a0101f..fbbd5a83561 100644 --- a/src/libstd/rt/io/pipe.rs +++ b/src/libstd/rt/io/pipe.rs @@ -86,6 +86,4 @@ impl Writer for PipeStream { } } } - - fn flush(&mut self) {} } diff --git a/src/libstd/rt/io/stdio.rs b/src/libstd/rt/io/stdio.rs index 3f34d32b350..eeffc20a336 100644 --- a/src/libstd/rt/io/stdio.rs +++ b/src/libstd/rt/io/stdio.rs @@ -294,8 +294,6 @@ impl Writer for StdWriter { Err(e) => io_error::cond.raise(e) } } - - fn flush(&mut self) { /* nothing to do */ } } #[cfg(test)] diff --git a/src/libstd/rt/rtio.rs b/src/libstd/rt/rtio.rs index 366388063d4..82ff8071896 100644 --- a/src/libstd/rt/rtio.rs +++ b/src/libstd/rt/rtio.rs @@ -173,7 +173,6 @@ pub trait RtioFileStream { fn pwrite(&mut self, buf: &[u8], offset: u64) -> Result<(), IoError>; fn seek(&mut self, pos: i64, whence: SeekStyle) -> Result; fn tell(&self) -> Result; - fn flush(&mut self) -> Result<(), IoError>; } pub trait RtioProcess {