Skip to main content

IntoCommand

Trait IntoCommand 

Source
pub trait IntoCommand<R: ProcessRunner>: Sealed { }
Expand description

What a CliClient verb accepts: either an argument list — built into a Command for the client’s program with its defaults (timeout, env, cancellation) applied — or a ready-made Command, run as-is.

This lets one verb serve both the common git.run(["status"]) and the customized git.run(git.command(["push"]).timeout(d)), removing the double-mention of the older git.run(git.command([…])) form. Implemented for argument containers ([S; N], Vec<S>, &[S] where S: AsRef<OsStr>) and for Command; sealed (not implementable downstream).

Either form receives the client’s defaults (timeout / env / default_cancel_on): an argument list builds a fresh command with them, and a ready-made Command has them filled into the gaps it left — its own explicit settings win, but a client-wide cancel token / timeout / env still reaches a per-call-customized command rather than being silently dropped.

Program note: a ready-made Command keeps its own program — the client fills only defaults, it does not substitute its program. So git_client.run(Command::new("rsync")) runs rsync, but with git’s env/timeout/cancel defaults grafted on (e.g. GIT_TERMINAL_PROMPT=0 on an rsync process). Pass a Command to a client’s verb only when you want that client’s defaults on it; otherwise build from an argument list (which uses the client’s own program) or run the command through its own client.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<R: ProcessRunner, S: AsRef<OsStr>, const N: usize> IntoCommand<R> for &[S; N]

Source§

impl<R: ProcessRunner, S: AsRef<OsStr>, const N: usize> IntoCommand<R> for [S; N]

Source§

impl<R: ProcessRunner, S: AsRef<OsStr>> IntoCommand<R> for &[S]

Source§

impl<R: ProcessRunner, S: AsRef<OsStr>> IntoCommand<R> for Vec<S>

Implementors§