pub struct EventsCommand {
pub executor: CommandExecutor,
/* private fields */
}
Expand description
Docker events command builder
Get real-time events from the Docker daemon.
§Example
use docker_wrapper::EventsCommand;
// Get all events
let events = EventsCommand::new()
.run()
.await?;
// Get container events only
let container_events = EventsCommand::new()
.filter("type", "container")
.format("json")
.run()
.await?;
Fields§
§executor: CommandExecutor
Command executor
Implementations§
Source§impl EventsCommand
impl EventsCommand
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new events command
§Example
use docker_wrapper::EventsCommand;
let cmd = EventsCommand::new();
Sourcepub fn filter(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn filter(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add a filter for events
§Example
use docker_wrapper::EventsCommand;
let cmd = EventsCommand::new()
.filter("type", "container")
.filter("event", "start")
.filter("container", "my-container");
Sourcepub fn format(self, format: impl Into<String>) -> Self
pub fn format(self, format: impl Into<String>) -> Self
Set output format
§Example
use docker_wrapper::EventsCommand;
// JSON format for programmatic parsing
let cmd = EventsCommand::new().format("json");
Sourcepub fn since(self, since: impl Into<String>) -> Self
pub fn since(self, since: impl Into<String>) -> Self
Show events created since this timestamp
§Example
use docker_wrapper::EventsCommand;
let cmd = EventsCommand::new()
.since("2023-01-01T00:00:00");
Sourcepub async fn run(&self) -> Result<EventsResult>
pub async fn run(&self) -> Result<EventsResult>
Execute the events command
§Errors
Returns an error if:
- The Docker daemon is not running
- Invalid filter or timestamp format
§Example
use docker_wrapper::EventsCommand;
let result = EventsCommand::new()
.filter("type", "container")
.format("json")
.run()
.await?;
if result.success() {
for event in result.parsed_events() {
println!("Event: {} on {}", event.action, event.actor.id);
}
}
Trait Implementations§
Source§impl Clone for EventsCommand
impl Clone for EventsCommand
Source§fn clone(&self) -> EventsCommand
fn clone(&self) -> EventsCommand
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 EventsCommand
impl Debug for EventsCommand
Source§impl Default for EventsCommand
impl Default for EventsCommand
Source§impl DockerCommand for EventsCommand
impl DockerCommand for EventsCommand
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 EventsCommand
impl RefUnwindSafe for EventsCommand
impl Send for EventsCommand
impl Sync for EventsCommand
impl Unpin for EventsCommand
impl UnwindSafe for EventsCommand
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