diff options
Diffstat (limited to 'src/libstd/sys/cloudabi')
| -rw-r--r-- | src/libstd/sys/cloudabi/stdio.rs | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/libstd/sys/cloudabi/stdio.rs b/src/libstd/sys/cloudabi/stdio.rs index 2cd3477cd51..81d79213f61 100644 --- a/src/libstd/sys/cloudabi/stdio.rs +++ b/src/libstd/sys/cloudabi/stdio.rs @@ -9,8 +9,10 @@ impl Stdin { pub fn new() -> io::Result<Stdin> { Ok(Stdin(())) } +} - pub fn read(&self, _: &mut [u8]) -> io::Result<usize> { +impl io::Read for Stdin { + fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> { Ok(0) } } @@ -19,15 +21,17 @@ impl Stdout { pub fn new() -> io::Result<Stdout> { Ok(Stdout(())) } +} - pub fn write(&self, _: &[u8]) -> io::Result<usize> { +impl io::Write for Stdout { + fn write(&mut self, _buf: &[u8]) -> io::Result<usize> { Err(io::Error::new( io::ErrorKind::BrokenPipe, "Stdout is not connected to any output in this environment", )) } - pub fn flush(&self) -> io::Result<()> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } } @@ -36,29 +40,18 @@ impl Stderr { pub fn new() -> io::Result<Stderr> { Ok(Stderr(())) } +} - pub fn write(&self, _: &[u8]) -> io::Result<usize> { +impl io::Write for Stderr { + fn write(&mut self, _buf: &[u8]) -> io::Result<usize> { Err(io::Error::new( io::ErrorKind::BrokenPipe, "Stderr is not connected to any output in this environment", )) } - pub fn flush(&self) -> io::Result<()> { - Ok(()) - } -} - -// FIXME: right now this raw stderr handle is used in a few places because -// std::io::stderr_raw isn't exposed, but once that's exposed this impl -// should go away -impl io::Write for Stderr { - fn write(&mut self, data: &[u8]) -> io::Result<usize> { - Stderr::write(self, data) - } - fn flush(&mut self) -> io::Result<()> { - Stderr::flush(self) + Ok(()) } } |
