Skip to main content

JobRunner

Struct JobRunner 

Source
pub struct JobRunner;
Expand description

The default runner: every run gets a fresh, private ProcessGroup owned by the run, so its tree is torn down when the run finishes (or its handle drops).

Implementations§

Source§

impl JobRunner

Source

pub fn new() -> JobRunner

Create a JobRunner.

Source

pub async fn start(&self, command: &Command) -> Result<RunningProcess, Error>

Start command and return a live handle, backed by a fresh private group the handle owns. Use this for streaming or incremental stdin.

Trait Implementations§

Source§

impl Clone for JobRunner

Source§

fn clone(&self) -> JobRunner

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 JobRunner

Source§

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

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

impl Default for JobRunner

Source§

fn default() -> JobRunner

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

impl ProcessRunner for JobRunner

Source§

fn output_string<'life0, 'life1, 'async_trait>( &'life0 self, command: &'life1 Command, ) -> Pin<Box<dyn Future<Output = Result<ProcessResult<String>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, JobRunner: 'async_trait,

Run command to completion, capturing stdout/stderr and the exit code. A non-zero exit is reported in the result, not raised.
Source§

fn start<'life0, 'life1, 'async_trait>( &'life0 self, command: &'life1 Command, ) -> Pin<Box<dyn Future<Output = Result<RunningProcess, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, JobRunner: 'async_trait,

Start command and return a live RunningProcess for streaming, readiness probes, or incremental consumption. Read more
Source§

fn output_bytes<'life0, 'life1, 'async_trait>( &'life0 self, command: &'life1 Command, ) -> Pin<Box<dyn Future<Output = Result<ProcessResult<Vec<u8>>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Run command to completion, capturing stdout as raw bytes (output_string captures it as lossy-UTF-8 text); stderr is still text. For binary tools — git cat-file, tar -c, an image transcoder — whose stdout is not UTF-8. Read more

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

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

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> 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> ProcessRunnerExt for T
where T: ProcessRunner + ?Sized,

Source§

fn run<'life0, 'life1, 'async_trait>( &'life0 self, command: &'life1 Command, ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: Sync + 'async_trait,

Run, require an accepted exit, and return trimmed stdout. Accepted is 0 by default, widened by Command::ok_codes; any other code is Error::Exit.
Source§

fn run_unit<'life0, 'life1, 'async_trait>( &'life0 self, command: &'life1 Command, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: Sync + 'async_trait,

Run for the side effect: require an accepted exit (0, or any code in Command::ok_codes), discard the output.
Source§

fn exit_code<'life0, 'life1, 'async_trait>( &'life0 self, command: &'life1 Command, ) -> Pin<Box<dyn Future<Output = Result<i32, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: Sync + 'async_trait,

Run and return just the exit code. A run that produced no code surfaces as an error — a timeout as Error::Timeout, a signal-kill as Error::Signalled — rather than a synthetic sentinel, mirroring ensure_success.
Source§

fn probe<'life0, 'life1, 'async_trait>( &'life0 self, command: &'life1 Command, ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: Sync + 'async_trait,

Run a predicate command and read its exit code as a boolean: exit 0Ok(true), exit 1Ok(false), anything else → Err (other code as Error::Exit, timeout as Error::Timeout, signal-kill as Error::Signalled). For commands whose exit code is the answer — git diff --quiet, grep -q, …
Source§

fn checked<'life0, 'life1, 'async_trait>( &'life0 self, command: &'life1 Command, ) -> Pin<Box<dyn Future<Output = Result<ProcessResult<String>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: Sync + 'async_trait,

Run, require an accepted exit (0 by default, widened by Command::ok_codes), and return the full captured result (untrimmed stdout). The building block for the parse/try_parse helpers — use it when you need the whole ProcessResult after success-checking, rather than just trimmed stdout (run) or the raw result (output_string). Read more
Source§

fn parse<'life0, 'life1, 'async_trait, T, F>( &'life0 self, command: &'life1 Command, parse: F, ) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, T: Send + 'async_trait, F: FnOnce(&str) -> T + Send + 'async_trait, Self: Sync + 'async_trait,

Run (requiring an accepted exit) and feed the captured stdout to an infallible parse closure — the shape of struct-returning CLI commands (git/jj --format output). Built on checked, but unlike it, fails loud on a bounded-buffer truncation so the parser never silently sees a clipped tail; returns the parsed value. Read more
Source§

fn try_parse<'life0, 'life1, 'async_trait, T, F>( &'life0 self, command: &'life1 Command, parse: F, ) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, T: Send + 'async_trait, F: FnOnce(&str) -> Result<T, Error> + Send + 'async_trait, Self: Sync + 'async_trait,

Run (requiring an accepted exit) and feed the captured stdout to a fallible parse closure — the shape of JSON deserialization, where a parse failure becomes Error::Parse (or whatever error the closure returns). Like parse it is built on checked, fails loud on truncation, and — being generic over F — is unavailable on a &dyn ProcessRunner; use a concrete runner or the Command::try_parse / CliClient::try_parse wrappers.
Source§

fn first_line<'life0, 'life1, 'async_trait, F>( &'life0 self, command: &'life1 Command, predicate: F, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, F: Fn(&str) -> bool + Send + 'async_trait, Self: Sync + 'async_trait,

Stream command’s stdout and return the first line matching predicate (None if the stream ends first), bounded by the command’s timeout (a Some deadline surfaces as Error::Timeout and tears the tree down). Read more
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 = 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.
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