From 73a91ad7b3739cbf27f9eb05bf4f8b38067a83c6 Mon Sep 17 00:00:00 2001 From: Ivan Petkov Date: Tue, 13 Aug 2019 20:53:02 -0700 Subject: [PATCH] signal: delete blocking Read/Write impls on ChildStd{in, out, err} (#1428) --- tokio-process/src/lib.rs | 41 +++++++--------------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/tokio-process/src/lib.rs b/tokio-process/src/lib.rs index d05b0ed27..6de69e387 100644 --- a/tokio-process/src/lib.rs +++ b/tokio-process/src/lib.rs @@ -132,7 +132,7 @@ extern crate lazy_static; #[macro_use] extern crate log; -use std::io::{self, Read, Write}; +use std::io; use std::process::{Command, ExitStatus, Output, Stdio}; use futures_core::future::TryFuture; @@ -613,9 +613,8 @@ impl Future for OutputAsync { /// The standard input stream for spawned children. /// -/// This type implements the `Write` trait to pass data to the stdin handle of -/// a child process. Note that this type is also "futures aware" meaning that it -/// is both (a) nonblocking and (b) will panic if used off of a future's task. +/// This type implements the `AsyncWrite` trait to pass data to the stdin handle of +/// handle of a child process asynchronously. #[derive(Debug)] pub struct ChildStdin { inner: imp::ChildStdin, @@ -623,10 +622,8 @@ pub struct ChildStdin { /// The standard output stream for spawned children. /// -/// This type implements the `Read` trait to read data from the stdout handle -/// of a child process. Note that this type is also "futures aware" meaning -/// that it is both (a) nonblocking and (b) will panic if used off of a -/// future's task. +/// This type implements the `AsyncRead` trait to read data from the stdout +/// handle of a child process asynchronously. #[derive(Debug)] pub struct ChildStdout { inner: imp::ChildStdout, @@ -634,25 +631,13 @@ pub struct ChildStdout { /// The standard error stream for spawned children. /// -/// This type implements the `Read` trait to read data from the stderr handle -/// of a child process. Note that this type is also "futures aware" meaning -/// that it is both (a) nonblocking and (b) will panic if used off of a -/// future's task. +/// This type implements the `AsyncRead` trait to read data from the stderr +/// handle of a child process asynchronously. #[derive(Debug)] pub struct ChildStderr { inner: imp::ChildStderr, } -impl Write for ChildStdin { - fn write(&mut self, bytes: &[u8]) -> io::Result { - self.inner.get_mut().write(bytes) - } - - fn flush(&mut self) -> io::Result<()> { - self.inner.get_mut().flush() - } -} - impl AsyncWrite for ChildStdin { fn poll_write( mut self: Pin<&mut Self>, @@ -671,12 +656,6 @@ impl AsyncWrite for ChildStdin { } } -impl Read for ChildStdout { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - self.inner.get_mut().read(buf) - } -} - impl AsyncRead for ChildStdout { fn poll_read( mut self: Pin<&mut Self>, @@ -687,12 +666,6 @@ impl AsyncRead for ChildStdout { } } -impl Read for ChildStderr { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - self.inner.get_mut().read(buf) - } -} - impl AsyncRead for ChildStderr { fn poll_read( mut self: Pin<&mut Self>,