Add read_to_end for AnonPipe
Add `read_to_end` method for `sys::{target}::pipe::AnonPipe`. This allows having a more optimized version of `read_to_end` for ChildStdout. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
This commit is contained in:
parent
f5418b09e8
commit
5479fe5f70
4 changed files with 17 additions and 1 deletions
|
@ -362,6 +362,10 @@ impl Read for ChildStdout {
|
||||||
fn is_read_vectored(&self) -> bool {
|
fn is_read_vectored(&self) -> bool {
|
||||||
self.inner.is_read_vectored()
|
self.inner.is_read_vectored()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
|
||||||
|
self.inner.read_to_end(buf)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsInner<AnonPipe> for ChildStdout {
|
impl AsInner<AnonPipe> for ChildStdout {
|
||||||
|
|
|
@ -58,6 +58,10 @@ impl AnonPipe {
|
||||||
self.0.is_read_vectored()
|
self.0.is_read_vectored()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn read_to_end(&self, buf: &mut Vec<u8>) -> io::Result<usize> {
|
||||||
|
self.0.read_to_end(buf)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
|
pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
|
||||||
self.0.write(buf)
|
self.0.write(buf)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,10 @@ impl AnonPipe {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn read_to_end(&self, buf: &mut Vec<u8>) -> io::Result<usize> {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
|
||||||
pub fn write(&self, _buf: &[u8]) -> io::Result<usize> {
|
pub fn write(&self, _buf: &[u8]) -> io::Result<usize> {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::os::windows::prelude::*;
|
use crate::os::windows::prelude::*;
|
||||||
|
|
||||||
use crate::ffi::OsStr;
|
use crate::ffi::OsStr;
|
||||||
use crate::io::{self, IoSlice, IoSliceMut};
|
use crate::io::{self, IoSlice, IoSliceMut, Read};
|
||||||
use crate::mem;
|
use crate::mem;
|
||||||
use crate::path::Path;
|
use crate::path::Path;
|
||||||
use crate::ptr;
|
use crate::ptr;
|
||||||
|
@ -261,6 +261,10 @@ impl AnonPipe {
|
||||||
self.inner.is_read_vectored()
|
self.inner.is_read_vectored()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn read_to_end(&self, buf: &mut Vec<u8>) -> io::Result<usize> {
|
||||||
|
self.handle().read_to_end(buf)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
|
pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let len = crate::cmp::min(buf.len(), c::DWORD::MAX as usize) as c::DWORD;
|
let len = crate::cmp::min(buf.len(), c::DWORD::MAX as usize) as c::DWORD;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue