pub fn build_native_executable(
spec: &NativeExecutableSpec<'_>,
cargo: impl FnMut() -> Command,
diagnostics: impl Write,
admit: impl FnMut() -> Result<()>,
spawn: impl FnMut(&mut Command) -> Result<OwnedChild>,
interrupted: impl FnMut() -> bool,
) -> Result<NativeExecutable, Box<dyn Error + Send + Sync>>Expand description
Build a selected native target and return Cargo’s reported executable.
The factory supplies the same Cargo prefix, working directory, environment
and network/tool policy for metadata and build. Commands add --locked, exact
package/target selection and Cargo’s JSON diagnostics format. Stdout is a
bounded-per-message protocol; rendered compiler diagnostics and piped stderr
stream to diagnostics. Other stderr configurations remain intact. Stdin is
null. spawn selects direct-child or owned-group custody and cleanup policy.
admit runs before each command factory. interrupted is polled during both
metadata and build capture; cancellation retains Host’s typed cleanup evidence.
The caller owns signal handlers and cancellation meaning.
Callers exclude source/config/tool mutation and retain artifact custody. No cache, installation, release admission, retry or elapsed-time default is added. Interrupted or rejected capture uses the caller-selected child cleanup.
§Errors
Refuses invalid selection before command effects, missing/ambiguous metadata or artifacts, malformed/oversized messages, sink failures and command failures. Original Host execution/status/cleanup causes remain downcastable.