pub struct RmiCommand {
pub executor: CommandExecutor,
/* private fields */
}
Expand description
Docker rmi command builder
Remove one or more images.
§Example
use docker_wrapper::RmiCommand;
// Remove a single image
RmiCommand::new("old-image:v1.0")
.run()
.await?;
// Force remove multiple images
RmiCommand::new_multiple(vec!["image1", "image2", "image3"])
.force()
.run()
.await?;
Fields§
§executor: CommandExecutor
Command executor
Implementations§
Source§impl RmiCommand
impl RmiCommand
Sourcepub fn new(image: impl Into<String>) -> Self
pub fn new(image: impl Into<String>) -> Self
Create a new rmi command for a single image
§Example
use docker_wrapper::RmiCommand;
let cmd = RmiCommand::new("old-image:latest");
Sourcepub fn new_multiple(images: Vec<impl Into<String>>) -> Self
pub fn new_multiple(images: Vec<impl Into<String>>) -> Self
Create a new rmi command for multiple images
§Example
use docker_wrapper::RmiCommand;
let cmd = RmiCommand::new_multiple(vec!["image1:latest", "image2:v1.0"]);
Sourcepub fn force(self) -> Self
pub fn force(self) -> Self
Force removal of the images
§Example
use docker_wrapper::RmiCommand;
let cmd = RmiCommand::new("stubborn-image:latest")
.force();
Sourcepub async fn run(&self) -> Result<RmiResult>
pub async fn run(&self) -> Result<RmiResult>
Execute the rmi command
§Errors
Returns an error if:
- The Docker daemon is not running
- Any of the specified images don’t exist
- Images are in use by containers (unless force is used)
§Example
use docker_wrapper::RmiCommand;
let result = RmiCommand::new("unused-image:latest")
.run()
.await?;
if result.success() {
println!("Removed {} images", result.removed_images().len());
}
Trait Implementations§
Source§impl Clone for RmiCommand
impl Clone for RmiCommand
Source§fn clone(&self) -> RmiCommand
fn clone(&self) -> RmiCommand
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for RmiCommand
impl Debug for RmiCommand
Source§impl DockerCommand for RmiCommand
impl DockerCommand for RmiCommand
Source§type Output = CommandOutput
type Output = CommandOutput
The output type this command produces
Source§fn build_command_args(&self) -> Vec<String>
fn build_command_args(&self) -> Vec<String>
Build the complete command arguments including subcommands
Source§fn get_executor(&self) -> &CommandExecutor
fn get_executor(&self) -> &CommandExecutor
Get the command executor for extensibility
Source§fn get_executor_mut(&mut self) -> &mut CommandExecutor
fn get_executor_mut(&mut self) -> &mut CommandExecutor
Get mutable command executor for extensibility
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,
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 execute_command<'life0, 'async_trait>(
&'life0 self,
command_args: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<CommandOutput>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn execute_command<'life0, 'async_trait>(
&'life0 self,
command_args: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<CommandOutput>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Helper method to execute the command with proper error handling
Source§fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self
fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self
Add a raw argument to the command (escape hatch)
Auto Trait Implementations§
impl Freeze for RmiCommand
impl RefUnwindSafe for RmiCommand
impl Send for RmiCommand
impl Sync for RmiCommand
impl Unpin for RmiCommand
impl UnwindSafe for RmiCommand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more