[−][src]Struct devx_cmd::ChildProcess
Wraps std::process::Child, kills and waits for the process on Drop.
It will log the fact that std::process::Child::kill was called in Drop.
You should use wait for the process to finish with any of the available
methods if you want to handle the error, otherwise it will be ignored.
Beware that ChildProcess holds an invariant that is not propagated to the
type system. The invariant is that if ChildProcess was not spawned via
Cmd::spawn_piped, then any methods that read the child's stdout will panic.
Implementations
impl ChildProcess[src]
pub fn wait(&mut self) -> Result<()>[src]
Waits for the process to finish. Returns an error if the process has finished with non-zero exit code.
You should use this method for processes spawned via Cmd::spawn
since the output of the command won't be read and returned,
but just written to this process's stdout (as stdout is inherited
with Cmd::spawn)
pub fn read_bytes(self) -> Result<Vec<u8>>[src]
Same as ChildProcess::read but reads any bytes sequence from the
child process stdout.
Panics
Same as for ChildProcess::read.
pub fn read(self) -> Result<String>[src]
Waits for the process to finish and returns all that it has written
to stdout. Returns an error if the process has finished with
non-zero exit code. Expects a valid utf8 bytes sequence (since it returns
a Rust String), if the process is not guaranteed to output valid utf8
you might want to use ChildProcess::read_bytes instead.
If Cmd::echo_cmd has been set to true then prints captured output to
stderr.
Panics
Panics if the process was spawned with non-piped stdout.
This method is expected to be used only for processes spawned via
Cmd::spawn_piped.
pub fn stdout_lines(&mut self) -> impl Iterator<Item = String> + '_[src]
Returns an iterator over the lines of data output to stdout by the child process.
Beware that the iterator buffers the output, thus when the it is
dropped the buffered data will be discarded and following reads
won't restore it.
Panics
Panics if some std::io::Error happens during the reading.
All invariants from ChildProcess::read_bytes apply here too.
Trait Implementations
impl Display for ChildProcess[src]
impl Drop for ChildProcess[src]
Auto Trait Implementations
impl RefUnwindSafe for ChildProcess
impl Send for ChildProcess
impl Sync for ChildProcess
impl Unpin for ChildProcess
impl UnwindSafe for ChildProcess
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,