Added io forwarding methods to the stdio structs
This commit is contained in:
@@ -96,7 +96,20 @@ impl Read for StdinRaw {
|
|||||||
unsafe fn initializer(&self) -> Initializer {
|
unsafe fn initializer(&self) -> Initializer {
|
||||||
Initializer::nop()
|
Initializer::nop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
|
||||||
|
self.0.read_to_end(buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
|
||||||
|
self.0.read_to_string(buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
|
||||||
|
self.0.read_exact(buf)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Write for StdoutRaw {
|
impl Write for StdoutRaw {
|
||||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||||
self.0.write(buf)
|
self.0.write(buf)
|
||||||
@@ -114,7 +127,20 @@ impl Write for StdoutRaw {
|
|||||||
fn flush(&mut self) -> io::Result<()> {
|
fn flush(&mut self) -> io::Result<()> {
|
||||||
self.0.flush()
|
self.0.flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
|
||||||
|
self.0.write_all(buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> {
|
||||||
|
self.0.write_all_vectored(bufs)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> {
|
||||||
|
self.0.write_fmt(fmt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Write for StderrRaw {
|
impl Write for StderrRaw {
|
||||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||||
self.0.write(buf)
|
self.0.write(buf)
|
||||||
@@ -132,6 +158,18 @@ impl Write for StderrRaw {
|
|||||||
fn flush(&mut self) -> io::Result<()> {
|
fn flush(&mut self) -> io::Result<()> {
|
||||||
self.0.flush()
|
self.0.flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
|
||||||
|
self.0.write_all(buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> {
|
||||||
|
self.0.write_all_vectored(bufs)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> {
|
||||||
|
self.0.write_fmt(fmt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Maybe<T> {
|
enum Maybe<T> {
|
||||||
@@ -420,6 +458,18 @@ impl Read for StdinLock<'_> {
|
|||||||
unsafe fn initializer(&self) -> Initializer {
|
unsafe fn initializer(&self) -> Initializer {
|
||||||
Initializer::nop()
|
Initializer::nop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
|
||||||
|
self.inner.read_to_end(buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
|
||||||
|
self.inner.read_to_string(buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
|
||||||
|
self.inner.read_exact(buf)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
@@ -427,9 +477,18 @@ impl BufRead for StdinLock<'_> {
|
|||||||
fn fill_buf(&mut self) -> io::Result<&[u8]> {
|
fn fill_buf(&mut self) -> io::Result<&[u8]> {
|
||||||
self.inner.fill_buf()
|
self.inner.fill_buf()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn consume(&mut self, n: usize) {
|
fn consume(&mut self, n: usize) {
|
||||||
self.inner.consume(n)
|
self.inner.consume(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> io::Result<usize> {
|
||||||
|
self.inner.read_until(byte, buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_line(&mut self, buf: &mut String) -> io::Result<usize> {
|
||||||
|
self.inner.read_line(buf)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "std_debug", since = "1.16.0")]
|
#[stable(feature = "std_debug", since = "1.16.0")]
|
||||||
@@ -596,6 +655,9 @@ impl Write for Stdout {
|
|||||||
fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> io::Result<()> {
|
fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> io::Result<()> {
|
||||||
self.lock().write_fmt(args)
|
self.lock().write_fmt(args)
|
||||||
}
|
}
|
||||||
|
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> {
|
||||||
|
self.lock().write_all_vectored(bufs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl Write for StdoutLock<'_> {
|
impl Write for StdoutLock<'_> {
|
||||||
@@ -612,6 +674,15 @@ impl Write for StdoutLock<'_> {
|
|||||||
fn flush(&mut self) -> io::Result<()> {
|
fn flush(&mut self) -> io::Result<()> {
|
||||||
self.inner.borrow_mut().flush()
|
self.inner.borrow_mut().flush()
|
||||||
}
|
}
|
||||||
|
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
|
||||||
|
self.inner.borrow_mut().write_all(buf)
|
||||||
|
}
|
||||||
|
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> {
|
||||||
|
self.inner.borrow_mut().write_all_vectored(bufs)
|
||||||
|
}
|
||||||
|
fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> {
|
||||||
|
self.inner.borrow_mut().write_fmt(fmt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "std_debug", since = "1.16.0")]
|
#[stable(feature = "std_debug", since = "1.16.0")]
|
||||||
@@ -770,6 +841,9 @@ impl Write for Stderr {
|
|||||||
fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> io::Result<()> {
|
fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> io::Result<()> {
|
||||||
self.lock().write_fmt(args)
|
self.lock().write_fmt(args)
|
||||||
}
|
}
|
||||||
|
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> {
|
||||||
|
self.lock().write_all_vectored(bufs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl Write for StderrLock<'_> {
|
impl Write for StderrLock<'_> {
|
||||||
@@ -786,6 +860,15 @@ impl Write for StderrLock<'_> {
|
|||||||
fn flush(&mut self) -> io::Result<()> {
|
fn flush(&mut self) -> io::Result<()> {
|
||||||
self.inner.borrow_mut().flush()
|
self.inner.borrow_mut().flush()
|
||||||
}
|
}
|
||||||
|
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
|
||||||
|
self.inner.borrow_mut().write_all(buf)
|
||||||
|
}
|
||||||
|
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> {
|
||||||
|
self.inner.borrow_mut().write_all_vectored(bufs)
|
||||||
|
}
|
||||||
|
fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> {
|
||||||
|
self.inner.borrow_mut().write_fmt(fmt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "std_debug", since = "1.16.0")]
|
#[stable(feature = "std_debug", since = "1.16.0")]
|
||||||
|
|||||||
Reference in New Issue
Block a user