Skip to main content

Capture

Struct Capture 

Source
pub struct Capture(/* private fields */);
Expand description

What a run keeps of one output stream of the child.

A constructor chooses the kind of capture. Capture::whole and Capture::lines return a builder for the settings of their kind, which RunOptions::stdout and RunOptions::stderr take as it is. The default is Capture::discard.

Implementations§

Source§

impl Capture

Source

pub const fn discard() -> Self

Returns a capture that sends the stream to the null device and keeps nothing.

Source

pub const fn inherit() -> Self

Returns a capture that sends the stream to the tool’s own stream and keeps nothing.

A child in a group of its own is in the background of the terminal. It can write there unless the terminal has tostop set, and it is stopped when it reads. A stopped child holds a run with no deadline. For a step that the person answers, use Scope::Child with Input::Inherit, so the child stays in the tool’s foreground group and the tool carries on when it ends. Ctrl-C then reaches both.

Source

pub const fn tail(limit: usize) -> Self

Returns a capture that reads the whole stream and keeps its last limit bytes.

Source

pub const fn whole(limit: usize) -> WholeCapture

Returns a capture that keeps the stream’s first limit bytes.

A stream longer than limit bytes is over its limit, and the run stops the child then unless WholeCapture::over says otherwise.

Source

pub const fn lines(queue: LineQueue, total: usize) -> LineCapture

Returns a capture that splits the stream into lines and pushes each line, without its end, to queue while the child runs. A last line with no end is pushed when the stream ends. The run keeps no bytes in its Captured.

The first time the stream passes total bytes, line ends and skipped lines included, the stream is over its limit. No line is pushed after that, and the run stops the child unless LineCapture::over says otherwise. Without LineCapture::line, one line has no limit of its own, and lines end at b'\n' unless LineCapture::end names another byte.

queue comes from line_queue and serves one run, which ends it when it returns.

Trait Implementations§

Source§

impl Clone for Capture

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Capture

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Capture

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<LineCapture> for Capture

Source§

fn from(lines: LineCapture) -> Self

Converts to this type from the input type.
Source§

impl From<WholeCapture> for Capture

Source§

fn from(whole: WholeCapture) -> Self

Converts to this type from the input type.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.