pub struct CommandSpec { /* private fields */ }Expand description
An argv-based candidate command with bounded execution policy.
Implementations§
Source§impl CommandSpec
impl CommandSpec
Sourcepub fn current_dir(self, path: impl Into<PathBuf>) -> Self
pub fn current_dir(self, path: impl Into<PathBuf>) -> Self
Sets the controlled child working directory.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Sets the maximum wall-clock execution time.
The value is an unconditional maximum bound on the whole bounded
execution: it is evaluated whether or not the direct child has already
exited, so run_bounded always returns. The deadline starts once the
spawn has returned, so a blocking spawn is not covered by it.
run_bounded states the exact bound, the teardown allowance, and
what a caller observes.
Sourcepub fn max_output_bytes(self, limit: usize) -> Self
pub fn max_output_bytes(self, limit: usize) -> Self
Sets the per-stream output bound.
The bound applies to each stream separately: stdout and stderr are
captured independently, so one run may capture up to twice the
configured value in total. A stream that exceeds the bound is reported
through CommandOutput::output_limited and its captured bytes are
discarded, so that stream is reported as empty.
Sourcepub fn environment(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn environment( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Adds one explicit environment variable; inherited environment is cleared.
Sourcepub fn stdin_data(self, data: impl Into<Vec<u8>>) -> Self
pub fn stdin_data(self, data: impl Into<Vec<u8>>) -> Self
Attaches a bounded stdin payload for the command to read.
The builder is infallible: the bound is enforced at execution time,
not here, so an oversized payload is rejected by run_bounded before
any child is spawned rather than by this builder.
Without a payload the child’s stdin is null, exactly as before. With a payload the child’s stdin is a pipe, and a dedicated writer thread writes the bytes and closes the pipe, so the command observes EOF when the payload has been delivered. The writer is bounded by the same deadline that bounds the output readers.
The payload is bounded by MAX_STDIN_BYTES, inclusively.