Skip to main content

Module exec

Module exec 

Source
Expand description

Subprocess execution with logging.

Ported from internal/executor/exec.go, internal/executor/client.go, internal/executor/interface.go, and internal/executor/context.go.

Real subprocess execution uses tokio::process::Command internally, bridged from the synchronous CommandRunner trait via a lazily started background tokio::runtime::Runtime (see runtime). Cancellation/timeouts race the child’s wait() against tokio::time::sleep with tokio::select!, killing the child with Child::kill() on timeout — see PORT_NOTES.md for the full architecture write-up and its known limitations.

Re-exports§

pub use context::ErrRunnerMissing;
pub use context::from_context;
pub use context::with_context;
pub use noop::NoopClient;
pub use repository::RepositoryExecutorDecorator;
pub use repository::get_repository_decorators;
pub use streamed::ExecStreamedOpts;

Modules§

context
Attaching a super::CommandRunner to an ambient execution context.
mise_decorator
Wraps commands with mise exec -- when mise is available in PATH.
noop
A CommandRunner that refuses to execute any command.
repository
Decorators applied to commands executed within a repository directory.
streamed
Streaming command execution (TTY scrolling area / prefixed lines / logger fallback).

Structs§

Client
Ported from Client in client.go.
ExecResult
Ported from Result in exec.go. Renamed to avoid shadowing std::result::Result.
Options
Ported from Options in exec.go.

Enums§

ExecError
Errors ported from the sentinel errors.New/fmt.Errorf values in exec.go.

Traits§

CommandRunner
Ported from the CommandRunner interface in interface.go.

Functions§

apply_sudo
Ported from ApplySudo, wired to the real environment.
apply_sudo_with
Ported from ApplySudo. Go stubs geteuid/lookPath as reassignable package-level vars for testing; Rust has no equivalent to mutable top-level function pointers without unsafe global state, so this port takes the euid getter and PATH lookup as explicit parameters instead. The zero-argument apply_sudo below is the production entry point, wiring in a real geteuid(2) call and look_path; ported tests call apply_sudo_with directly. See PORT_NOTES.md.
check
Ported from the package-level check function, with no deadline. See check_with_timeout for the deviation that threads one through explicitly (Go’s version takes a deadline via the ambient context.Context argument every caller already has).
check_with_timeout
Ported from the package-level check function. See PORT_NOTES.md: this crate has no ambient context to carry Go’s caller-supplied deadline, so timeout is threaded through explicitly as a disclosed deviation from a literal 1:1 signature match.
look_path
Ported from lookPath (aliased to exec.LookPath in Go). Minimal manual $PATH search, matching mise_decorator’s existing approach of avoiding a dependency on an external which-style crate for this narrow use.
read_stdout
Ported from the package-level readStdout function.
run
Ported from the package-level run function.
run_sudo
Ported from runSudo, wired to the real environment via apply_sudo.
run_sudo_with
Ported from runSudo. See apply_sudo_with’s doc comment: this port takes the euid getter and PATH lookup as explicit parameters (rather than Go’s reassignable package-level vars) so tests can stub them without touching real root privileges or the real sudo binary. Runs synchronously with inherited stdio (std::process::Command), matching Go’s runSudo, which deliberately does not capture output so sudo can prompt on the controlling terminal.

Type Aliases§

LogLevel
Log level for streamed/buffered output. Ported from slog.Level usage in Options; this crate uses tracing::Level as the idiomatic Rust equivalent of Go’s log/slog (see PORT_NOTES.md).