Skip to main content

RunningCommand

Struct RunningCommand 

Source
pub struct RunningCommand { /* private fields */ }
Expand description

A command BashTool::spawn started (spec 3.1 §10 D10).

wait for it to exit, then read its result; or kill it. Dropping it kills the command’s processes, so a caller that keeps a command running — a background shell — keeps this value.

Implementations§

Source§

impl RunningCommand

Source

pub fn command(&self) -> &str

The command as it was started.

Source

pub fn pid(&self) -> Option<u32>

The process id of the shell, which leads the command’s process group on Unix; None when the platform gave none.

Source

pub fn elapsed(&self) -> Duration

How long the command has run.

Source

pub async fn wait(&mut self) -> Result<Option<i32>>

Waits for the command to exit and its output to end; its exit code, None when a signal ended it. Cancel-safe: a wait dropped before it returns can be called again.

§Errors

Returns the error from waiting on the process.

Source

pub fn is_finished(&self) -> bool

Whether the command has exited and been waited for.

Source

pub fn kill(&self)

Kills the command’s processes; wait returns soon after.

Source

pub async fn kill_and_wait(&mut self)

Kills the command’s processes and waits, briefly, for them to be reaped.

Source

pub fn output_bytes(&self) -> u64

Bytes the command has written to stdout and stderr so far.

Source

pub fn last_line(&self) -> Option<String>

The last line the command has written, at most 200 characters.

Source

pub fn keep_output(&self) -> Result<String>

Sends the command’s output to a file from the output store, from its first byte and whatever the result needs, and returns the file’s id.

§Errors

Returns an error when the tool has no output store or the store cannot create the file.

Source

pub fn result(&self, exit_code: Option<i32>) -> Value

The result of the call: { command, exit_code, stdout, stderr, truncated }, plus output_id when the output was cut and an output store keeps the whole of it.

Trait Implementations§

Source§

impl Debug for RunningCommand

Source§

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

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

impl Drop for RunningCommand

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for RunningCommand

§

impl !UnwindSafe for RunningCommand

§

impl Forget for RunningCommand

§

impl Freeze for RunningCommand
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const ArcInner<Collector> is !null: Freeze, PhantomData<ArcInner<Collector>>: Freeze, *const ArcInner<Notify> is !null: Freeze, PhantomData<ArcInner<Notify>>: Freeze, *const Header is !null: Freeze, PhantomData<Result<Option<i32>, Error>>: Freeze,

§

impl Move for RunningCommand

§

impl Send for RunningCommand
where RawVecInner: Send, Arc<Collector>: Send, Arc<Notify>: Send, JoinHandle<Result<Option<i32>, Error>>: Send,

§

impl Sync for RunningCommand
where RawVecInner: Sync, Arc<Collector>: Sync, Arc<Notify>: Sync, JoinHandle<Result<Option<i32>, Error>>: Sync,

§

impl Unpin for RunningCommand
where *const u8 is !null: Unpin, Arc<Collector>: Unpin, Arc<Notify>: Unpin, JoinHandle<Result<Option<i32>, Error>>: Unpin,

§

impl UnsafeUnpin for RunningCommand
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<Collector> is !null: UnsafeUnpin, PhantomData<ArcInner<Collector>>: UnsafeUnpin, *const ArcInner<Notify> is !null: UnsafeUnpin, PhantomData<ArcInner<Notify>>: UnsafeUnpin, *const Header is !null: UnsafeUnpin, PhantomData<Result<Option<i32>, Error>>: UnsafeUnpin,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more