pub struct PortCommand {
pub executor: CommandExecutor,
/* private fields */
}
Expand description
Docker port command builder
List port mappings or a specific mapping for a container.
§Example
use docker_wrapper::PortCommand;
// List all port mappings
let ports = PortCommand::new("my-container")
.run()
.await?;
// Get specific port mapping
let port = PortCommand::new("my-container")
.port(80)
.run()
.await?;
Fields§
§executor: CommandExecutor
Command executor
Implementations§
Source§impl PortCommand
impl PortCommand
Sourcepub fn new(container: impl Into<String>) -> Self
pub fn new(container: impl Into<String>) -> Self
Create a new port command
§Example
use docker_wrapper::PortCommand;
let cmd = PortCommand::new("my-container");
Sourcepub fn port(self, port: u16) -> Self
pub fn port(self, port: u16) -> Self
Query specific port mapping
§Example
use docker_wrapper::PortCommand;
let cmd = PortCommand::new("my-container")
.port(80);
Sourcepub async fn run(&self) -> Result<PortResult>
pub async fn run(&self) -> Result<PortResult>
Execute the port command
§Errors
Returns an error if:
- The Docker daemon is not running
- The container doesn’t exist
§Example
use docker_wrapper::PortCommand;
let result = PortCommand::new("my-container")
.run()
.await?;
if result.success() {
for mapping in result.port_mappings() {
println!("{}:{} -> {}", mapping.host_ip, mapping.host_port, mapping.container_port);
}
}
Trait Implementations§
Source§impl Clone for PortCommand
impl Clone for PortCommand
Source§fn clone(&self) -> PortCommand
fn clone(&self) -> PortCommand
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 PortCommand
impl Debug for PortCommand
Source§impl DockerCommand for PortCommand
impl DockerCommand for PortCommand
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 PortCommand
impl RefUnwindSafe for PortCommand
impl Send for PortCommand
impl Sync for PortCommand
impl Unpin for PortCommand
impl UnwindSafe for PortCommand
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