Skip to main content

CommandCapture

Struct CommandCapture 

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

Accumulates an invocation, then writes it into a RunManifest (claim) and/or reconstructs an argv for re-execution.

Implementations§

Source§

impl CommandCapture

Source

pub fn new(subcommand: impl Into<String>) -> CommandCapture

Start capturing an invocation of subcommand (e.g. "variants").

Source

pub fn input( &mut self, flag: &str, path: &Path, ) -> Result<&mut CommandCapture, Error>

A content-addressed input operand; hashes the file and records it.

Source

pub fn output( &mut self, flag: &str, path: &Path, ) -> Result<&mut CommandCapture, Error>

A content-addressed output operand; hashes the file and records it.

Source

pub fn input_hashed( &mut self, flag: &str, path: &str, blake3: &str, ) -> &mut CommandCapture

Input operand with a precomputed hash (when the caller already hashed it, and in tests). path is recorded into inputs[] for humans / verify to re-hash.

Source

pub fn output_hashed( &mut self, flag: &str, path: &str, blake3: &str, ) -> &mut CommandCapture

Output operand with a precomputed hash.

Source

pub fn opt(&mut self, flag: &str, value: impl ToString) -> &mut CommandCapture

An option with a value, e.g. ("--max-depth", 1000).

Source

pub fn flag(&mut self, flag: &str) -> &mut CommandCapture

A bare flag, e.g. "--enforce".

Source

pub fn flag_if(&mut self, cond: bool, flag: &str) -> &mut CommandCapture

Record flag only when cond (so a false boolean leaves no trace).

Source

pub fn record_into(self, m: &mut RunManifest)

Write the capture into a manifest’s claim: the command recipe, the derived inputs[]/outputs[], the discrete params (mechanical flag→key projection), and the inferred mode. Call before finalize(). Measurement fields remain the caller’s responsibility (recorded separately, relocated by finalize).

Source

pub fn argv_from_command( command: &str, locate_input: &dyn Fn(&str) -> Option<String>, temp_output: &dyn Fn(&str) -> String, ) -> Result<Vec<String>, String>

Reconstruct an argv from a recorded command: substitute each @in:<h> with the located input path and each @out:<h> with a caller-supplied temp path. Errors (naming the hash) if an input cannot be located.

Trait Implementations§

Source§

impl Debug for CommandCapture

Source§

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

Formats the value using the given formatter. 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> 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.