Skip to main content

OutputCapture

Struct OutputCapture 

Source
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

Source

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).

Source

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.

Source

pub fn snapshot(&self) -> CapturedOutput

What has been captured so far.

Source

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.

Source

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.

Source

pub fn finish_within(&mut self, timeout: Duration) -> CapturedOutput

Like finish but gives up after timeout (a grandchild that inherited the pipe keeps it open after the child is gone) and returns what was captured so far. Never joins the thread; finish can still do that later.

Source

pub fn is_finished(&self) -> bool

True once the stream has ended (or failed).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.