pub struct SaveCommand {
pub executor: CommandExecutor,
/* private fields */
}
Expand description
Docker save command builder
Save one or more images to a tar archive (streamed to STDOUT by default).
§Example
use docker_wrapper::SaveCommand;
use std::path::Path;
// Save image to file
SaveCommand::new("alpine:latest")
.output(Path::new("alpine.tar"))
.run()
.await?;
// Save multiple images
SaveCommand::new_multiple(vec!["alpine:latest", "nginx:latest"])
.output(Path::new("images.tar"))
.run()
.await?;
Fields§
§executor: CommandExecutor
Command executor
Implementations§
Source§impl SaveCommand
impl SaveCommand
Sourcepub fn new(image: impl Into<String>) -> Self
pub fn new(image: impl Into<String>) -> Self
Create a new save command for a single image
§Example
use docker_wrapper::SaveCommand;
let cmd = SaveCommand::new("alpine:latest");
Sourcepub fn new_multiple(images: Vec<impl Into<String>>) -> Self
pub fn new_multiple(images: Vec<impl Into<String>>) -> Self
Create a new save command for multiple images
§Example
use docker_wrapper::SaveCommand;
let cmd = SaveCommand::new_multiple(vec!["alpine:latest", "nginx:latest"]);
Sourcepub fn output(self, path: &Path) -> Self
pub fn output(self, path: &Path) -> Self
Set output file path
§Example
use docker_wrapper::SaveCommand;
use std::path::Path;
let cmd = SaveCommand::new("alpine:latest")
.output(Path::new("alpine.tar"));
Sourcepub async fn run(&self) -> Result<SaveResult>
pub async fn run(&self) -> Result<SaveResult>
Execute the save command
§Errors
Returns an error if:
- The Docker daemon is not running
- Any of the specified images don’t exist
- Cannot write to the output file
§Example
use docker_wrapper::SaveCommand;
use std::path::Path;
let result = SaveCommand::new("alpine:latest")
.output(Path::new("alpine.tar"))
.run()
.await?;
if result.success() {
println!("Images saved successfully");
}
Trait Implementations§
Source§impl Clone for SaveCommand
impl Clone for SaveCommand
Source§fn clone(&self) -> SaveCommand
fn clone(&self) -> SaveCommand
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 SaveCommand
impl Debug for SaveCommand
Source§impl DockerCommand for SaveCommand
impl DockerCommand for SaveCommand
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 SaveCommand
impl RefUnwindSafe for SaveCommand
impl Send for SaveCommand
impl Sync for SaveCommand
impl Unpin for SaveCommand
impl UnwindSafe for SaveCommand
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