[go: up one dir, main page]

[][src]Struct duct::Handle

pub struct Handle { /* fields omitted */ }

A handle to a running expression, returned by the start method.

Calling start followed by output on the handle is equivalent to run. Note that unlike std::process::Child, most of the methods on Handle take &self rather than &mut self, and a Handle may be shared between multiple threads.

Like std::process::Child, Handle doesn't do anything special in its destructor. If a Handle goes out of scope without calling wait or similar, child processes and background threads will keep running, and they'll leave zombies when they exit.

See the shared_child crate for implementation details behind making handles thread safe.

Methods

impl Handle[src]

pub fn wait(&self) -> Result<&Output>[src]

Wait for the running expression to finish, and return a reference to its std::process::Output. Multiple threads may wait at the same time.

Errors

In addition to all the IO errors possible with std::process::Child, wait will return an ErrorKind::Other IO error if child returns a non-zero exit status. To suppress this error and return an Output even when the exit status is non-zero, use the unchecked method.

pub fn try_wait(&self) -> Result<Option<&Output>>[src]

Check whether the running expression is finished. If it is, return a reference to its std::process::Output. If it's still running, return Ok(None).

Errors

In addition to all the IO errors possible with std::process::Child, try_wait will return an ErrorKind::Other IO error if child returns a non-zero exit status. To suppress this error and return an Output even when the exit status is non-zero, use the unchecked method.

pub fn into_output(self) -> Result<Output>[src]

Wait for the running expression to finish, and then return a std::process::Output object containing the results, including any captured output. This consumes the Handle. Calling start followed by into_output is equivalent to run.

Errors

In addition to all the IO errors possible with std::process::Child, into_output will return an ErrorKind::Other IO error if child returns a non-zero exit status. To suppress this error and return an Output even when the exit status is non-zero, use the unchecked method.

pub fn kill(&self) -> Result<()>[src]

Kill the running expression and await all the child processes. Any errors that would normally result from a non-zero exit status are ignored, as with unchecked.

Trait Implementations

impl HandleExt for Handle[src]

impl Debug for Handle[src]

Auto Trait Implementations

impl Send for Handle

impl Sync for Handle

impl Unpin for Handle

impl !RefUnwindSafe for Handle

impl !UnwindSafe for Handle

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]