Trait DockerCommand

Source
pub trait DockerCommand {
    type Output;

    // Required methods
    fn command_name(&self) -> &'static str;
    fn build_args(&self) -> Vec<String>;
    fn execute<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self;
    fn args<I, S>(&mut self, args: I) -> &mut Self
       where I: IntoIterator<Item = S>,
             S: AsRef<OsStr>;
    fn flag(&mut self, flag: &str) -> &mut Self;
    fn option(&mut self, key: &str, value: &str) -> &mut Self;
}
Expand description

Base trait for all Docker commands

Required Associated Types§

Source

type Output

The output type this command produces

Required Methods§

Source

fn command_name(&self) -> &'static str

Get the command name (e.g., “run”, “exec”, “ps”)

Source

fn build_args(&self) -> Vec<String>

Build the command arguments

Source

fn execute<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute the command and return the typed output

Source

fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self

Add a raw argument to the command (escape hatch)

Source

fn args<I, S>(&mut self, args: I) -> &mut Self
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Add multiple raw arguments to the command (escape hatch)

Source

fn flag(&mut self, flag: &str) -> &mut Self

Add a flag option (e.g., –detach, –rm)

Source

fn option(&mut self, key: &str, value: &str) -> &mut Self

Add a key-value option (e.g., –name value, –env key=value)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§