pub struct HistoryCommand {
pub executor: CommandExecutor,
/* private fields */
}
Expand description
Docker history command builder
Show the history of an image, including layer information.
§Example
use docker_wrapper::HistoryCommand;
// Show image history
let history = HistoryCommand::new("nginx:latest")
.run()
.await?;
for layer in history.layers() {
println!("{}: {} ({})", layer.id, layer.created_by, layer.size);
}
Fields§
§executor: CommandExecutor
Command executor
Implementations§
Source§impl HistoryCommand
impl HistoryCommand
Sourcepub fn new(image: impl Into<String>) -> Self
pub fn new(image: impl Into<String>) -> Self
Create a new history command
§Example
use docker_wrapper::HistoryCommand;
let cmd = HistoryCommand::new("nginx:latest");
Sourcepub fn human(self, human: bool) -> Self
pub fn human(self, human: bool) -> Self
Show human readable sizes
§Example
use docker_wrapper::HistoryCommand;
let cmd = HistoryCommand::new("nginx:latest")
.human(true);
Sourcepub fn no_trunc(self, no_trunc: bool) -> Self
pub fn no_trunc(self, no_trunc: bool) -> Self
Don’t truncate output
§Example
use docker_wrapper::HistoryCommand;
let cmd = HistoryCommand::new("nginx:latest")
.no_trunc(true);
Sourcepub fn quiet(self, quiet: bool) -> Self
pub fn quiet(self, quiet: bool) -> Self
Show quiet output (only image IDs)
§Example
use docker_wrapper::HistoryCommand;
let cmd = HistoryCommand::new("nginx:latest")
.quiet(true);
Sourcepub fn format(self, format: impl Into<String>) -> Self
pub fn format(self, format: impl Into<String>) -> Self
Format output using a Go template
§Example
use docker_wrapper::HistoryCommand;
let cmd = HistoryCommand::new("nginx:latest")
.format("{{.ID}}: {{.CreatedBy}}");
Sourcepub async fn run(&self) -> Result<HistoryResult>
pub async fn run(&self) -> Result<HistoryResult>
Execute the history command
§Errors
Returns an error if:
- The Docker daemon is not running
- The image doesn’t exist
§Example
use docker_wrapper::HistoryCommand;
let result = HistoryCommand::new("nginx:latest")
.run()
.await?;
if result.success() {
println!("Image layers:");
for layer in result.layers() {
println!("{}: {}", layer.id, layer.size);
}
}
Trait Implementations§
Source§impl Clone for HistoryCommand
impl Clone for HistoryCommand
Source§fn clone(&self) -> HistoryCommand
fn clone(&self) -> HistoryCommand
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 HistoryCommand
impl Debug for HistoryCommand
Source§impl DockerCommand for HistoryCommand
impl DockerCommand for HistoryCommand
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 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 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_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 HistoryCommand
impl RefUnwindSafe for HistoryCommand
impl Send for HistoryCommand
impl Sync for HistoryCommand
impl Unpin for HistoryCommand
impl UnwindSafe for HistoryCommand
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