Skip to main content

CaptureSingle

Struct CaptureSingle 

Source
pub struct CaptureSingle<S: StreamMarker> { /* private fields */ }
Expand description

Builder for capturing a single stream from a command.

The type parameter S indicates which stream is being captured: Stdout or Stderr.

Implementations§

Source§

impl<S: StreamMarker> CaptureSingle<S>

Source

pub fn accept_nonzero_exit(self) -> Self

Accept non-zero exit status instead of treating it as an error.

Source§

impl CaptureSingle<Stdout>

Source

pub fn stderr_capture(self) -> CaptureAll

Also capture stderr, transitioning to CaptureAll.

Source

pub fn stderr_null(self) -> Self

Redirect stderr to /dev/null.

Source

pub fn stderr_inherit(self) -> Self

Inherit stderr from the parent process (default).

Source

pub fn stdout_null(self) -> Command

Stop capturing stdout (null), transitioning back to Command.

Source

pub fn stdout_inherit(self) -> Command

Stop capturing stdout (inherit), transitioning back to Command.

Source

pub async fn run(self) -> Result<CaptureSingleResult, CommandError>

Execute the command and return captured stdout.

Source

pub async fn bytes(self) -> Result<Vec<u8>, CommandError>

Execute the command and return captured stdout as bytes.

Source

pub async fn string(self) -> Result<String, CommandError>

Execute the command and return captured stdout as a UTF-8 string.

Source§

impl CaptureSingle<Stderr>

Source

pub fn stdout_capture(self) -> CaptureAll

Also capture stdout, transitioning to CaptureAll.

Source

pub fn stdout_null(self) -> Self

Redirect stdout to /dev/null.

Source

pub fn stdout_inherit(self) -> Self

Inherit stdout from the parent process (default).

Source

pub fn stderr_null(self) -> Command

Stop capturing stderr (null), transitioning back to Command.

Source

pub fn stderr_inherit(self) -> Command

Stop capturing stderr (inherit), transitioning back to Command.

Source

pub async fn run(self) -> Result<CaptureSingleResult, CommandError>

Execute the command and return captured stderr.

Source

pub async fn bytes(self) -> Result<Vec<u8>, CommandError>

Execute the command and return captured stderr as bytes.

Source

pub async fn string(self) -> Result<String, CommandError>

Execute the command and return captured stderr as a UTF-8 string.

Auto Trait Implementations§

§

impl<S> Freeze for CaptureSingle<S>

§

impl<S> !RefUnwindSafe for CaptureSingle<S>

§

impl<S> Send for CaptureSingle<S>
where S: Send,

§

impl<S> Sync for CaptureSingle<S>
where S: Sync,

§

impl<S> Unpin for CaptureSingle<S>
where S: Unpin,

§

impl<S> !UnwindSafe for CaptureSingle<S>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.