pub struct CpCommand {
pub executor: CommandExecutor,
/* private fields */
}
Expand description
Docker cp command builder
Copy files/folders between a container and the local filesystem.
Use -
as the source to read from stdin or as the destination to write to stdout.
§Example
use docker_wrapper::CpCommand;
use std::path::Path;
// Copy from container to host
CpCommand::from_container("my-container", "/app/config.yml")
.to_host(Path::new("./config.yml"))
.run()
.await?;
// Copy from host to container
CpCommand::from_host(Path::new("./data.txt"))
.to_container("my-container", "/data/data.txt")
.run()
.await?;
Fields§
§executor: CommandExecutor
Command executor
Implementations§
Source§impl CpCommand
impl CpCommand
Sourcepub fn from_container(
container: impl Into<String>,
path: impl Into<String>,
) -> Self
pub fn from_container( container: impl Into<String>, path: impl Into<String>, ) -> Self
Create a cp command copying from container to host
§Example
use docker_wrapper::CpCommand;
use std::path::Path;
let cmd = CpCommand::from_container("my-container", "/etc/config")
.to_host(Path::new("./config"));
Sourcepub fn from_host(path: &Path) -> Self
pub fn from_host(path: &Path) -> Self
Create a cp command copying from host to container
§Example
use docker_wrapper::CpCommand;
use std::path::Path;
let cmd = CpCommand::from_host(Path::new("./file.txt"))
.to_container("my-container", "/app/file.txt");
Sourcepub fn to_container(
self,
container: impl Into<String>,
path: impl Into<String>,
) -> Self
pub fn to_container( self, container: impl Into<String>, path: impl Into<String>, ) -> Self
Set destination in container
Sourcepub fn archive(self) -> Self
pub fn archive(self) -> Self
Archive mode - preserve UIDs/GIDs and permissions
§Example
use docker_wrapper::CpCommand;
use std::path::Path;
let cmd = CpCommand::from_container("my-container", "/app")
.to_host(Path::new("./app-backup"))
.archive();
Sourcepub fn follow_link(self) -> Self
pub fn follow_link(self) -> Self
Follow symbolic links in source
Trait Implementations§
Source§impl DockerCommand for CpCommand
impl DockerCommand for CpCommand
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 CpCommand
impl RefUnwindSafe for CpCommand
impl Send for CpCommand
impl Sync for CpCommand
impl Unpin for CpCommand
impl UnwindSafe for CpCommand
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