pub struct Runner { /* private fields */ }std only.Expand description
An external runner that executes program text in a language runtime.
The pattern consumes text conforming to the runtime’s grammar and produces the execution result as text. This wrapper transports input and output as bytes; the external program parses and executes the input.
Each definition is passed as a --define=<key>=<value> argument; its meaning
is determined by the runtime. Input and output use the buffering and
stream-handling behavior described in crate::programs. For direct
control over command configuration, use Executor instead.
Implementations§
Source§impl Runner
impl Runner
Sourcepub fn new(
program: impl AsRef<OsStr>,
input: Input,
output: Output,
options: RunnerOptions,
) -> Self
pub fn new( program: impl AsRef<OsStr>, input: Input, output: Output, options: RunnerOptions, ) -> Self
Configures a runner without starting it.
Adds one --define=<key>=<value> argument per entry in options.define,
in BTreeMap key order, followed by options.other. Duplicate keys have
already been collapsed by the map; ordered or repeated definitions can
instead be supplied through options.other. Names must be nonempty and
contain no =; values may be empty or contain =. This constructor does
not validate them. The input and output values select stdin and stdout;
stderr is captured for failure diagnostics.
Sourcepub async fn execute(&mut self) -> RunnerResult
pub async fn execute(&mut self) -> RunnerResult
Sends the remaining input to a new child and returns captured stdout bytes.
§Errors
Returns an ExecutorError if spawning, copying input, or waiting fails,
or if the runner exits unsuccessfully.