pub struct TopCommand {
pub executor: CommandExecutor,
/* private fields */
}
Expand description
Docker top command builder
Display the running processes of a container.
§Example
use docker_wrapper::TopCommand;
// Show processes in a container
let processes = TopCommand::new("my-container")
.run()
.await?;
// Use custom ps options
let detailed = TopCommand::new("my-container")
.ps_options("aux")
.run()
.await?;
Fields§
§executor: CommandExecutor
Command executor
Implementations§
Source§impl TopCommand
impl TopCommand
Sourcepub fn new(container: impl Into<String>) -> Self
pub fn new(container: impl Into<String>) -> Self
Create a new top command
§Example
use docker_wrapper::TopCommand;
let cmd = TopCommand::new("my-container");
Sourcepub fn ps_options(self, options: impl Into<String>) -> Self
pub fn ps_options(self, options: impl Into<String>) -> Self
Set ps command options
§Example
use docker_wrapper::TopCommand;
// Show detailed process information
let cmd = TopCommand::new("my-container")
.ps_options("aux");
// Show processes with specific format
let cmd = TopCommand::new("my-container")
.ps_options("-eo pid,ppid,cmd,%mem,%cpu");
Sourcepub async fn run(&self) -> Result<TopResult>
pub async fn run(&self) -> Result<TopResult>
Execute the top command
§Errors
Returns an error if:
- The Docker daemon is not running
- The container doesn’t exist
- The container is not running
§Example
use docker_wrapper::TopCommand;
let result = TopCommand::new("my-container")
.run()
.await?;
if result.success() {
println!("Container processes:\n{}", result.output().stdout);
for process in result.processes() {
println!("PID: {}, CMD: {}", process.pid, process.command);
}
}
Sourcepub fn get_executor(&self) -> &CommandExecutor
pub fn get_executor(&self) -> &CommandExecutor
Gets the command executor
Sourcepub fn get_executor_mut(&mut self) -> &mut CommandExecutor
pub fn get_executor_mut(&mut self) -> &mut CommandExecutor
Gets the command executor mutably
Sourcepub fn build_command_args(&self) -> Vec<String>
pub fn build_command_args(&self) -> Vec<String>
Builds the command arguments for Docker top
Trait Implementations§
Source§impl Clone for TopCommand
impl Clone for TopCommand
Source§fn clone(&self) -> TopCommand
fn clone(&self) -> TopCommand
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 TopCommand
impl Debug for TopCommand
Source§impl DockerCommand for TopCommand
impl DockerCommand for TopCommand
Source§type Output = CommandOutput
type Output = CommandOutput
The output type this command produces
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 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 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 TopCommand
impl RefUnwindSafe for TopCommand
impl Send for TopCommand
impl Sync for TopCommand
impl Unpin for TopCommand
impl UnwindSafe for TopCommand
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