pub struct OutputCapture { /* private fields */ }Expand description
A background drain of one output stream into a bounded byte buffer. See the module documentation.
Implementations§
Source§impl OutputCapture
impl OutputCapture
Sourcepub fn capture<R: Read + Send + 'static>(reader: R, max_bytes: usize) -> Self
pub fn capture<R: Read + Send + 'static>(reader: R, max_bytes: usize) -> Self
Drains reader on a thread, keeping the first max_bytes bytes. Best effort: if the
thread cannot be spawned the capture holds nothing (use
try_capture to learn that).
Sourcepub fn try_capture<R: Read + Send + 'static>(
reader: R,
max_bytes: usize,
) -> Result<Self>
pub fn try_capture<R: Read + Send + 'static>( reader: R, max_bytes: usize, ) -> Result<Self>
Like capture, but returns the operating-system error when the drain
thread cannot be spawned.
Sourcepub fn snapshot(&self) -> CapturedOutput
pub fn snapshot(&self) -> CapturedOutput
What has been captured so far.
Sourcepub fn take_error(&self) -> Option<Error>
pub fn take_error(&self) -> Option<Error>
The error that stopped the drain before the end of the stream, taken once. None when
the stream ended cleanly or is still open.
Sourcepub fn finish(&mut self) -> CapturedOutput
pub fn finish(&mut self) -> CapturedOutput
Waits for the stream to end (the child exited and no grandchild holds the pipe), then returns the complete capture.
Sourcepub fn finish_within(&mut self, timeout: Duration) -> CapturedOutput
pub fn finish_within(&mut self, timeout: Duration) -> CapturedOutput
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
True once the stream has ended (or failed).
Auto Trait Implementations§
impl !RefUnwindSafe for OutputCapture
impl !UnwindSafe for OutputCapture
impl Freeze for OutputCapture
impl Send for OutputCapture
impl Sync for OutputCapture
impl Unpin for OutputCapture
impl UnsafeUnpin for OutputCapture
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more