@@ -6,7 +6,7 @@ use super::{CommandExecutor, CommandOutput, DockerCommand};
66use crate :: error:: Result ;
77use async_trait:: async_trait;
88
9- /// Docker attach command builder
9+ /// Docker attach command builder.
1010///
1111/// Attach local standard input, output, and error streams to a running container.
1212///
@@ -16,12 +16,12 @@ use async_trait::async_trait;
1616/// use docker_wrapper::AttachCommand;
1717///
1818/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
19- /// // Attach to a running container
19+ /// // attach to a running container
2020/// AttachCommand::new("my-container")
2121/// .run()
2222/// .await?;
2323///
24- /// // Attach without stdin
24+ /// // attach without stdin
2525/// AttachCommand::new("my-container")
2626/// .no_stdin()
2727/// .run()
@@ -31,20 +31,20 @@ use async_trait::async_trait;
3131/// ```
3232#[ derive( Debug , Clone ) ]
3333pub struct AttachCommand {
34- /// Container name or ID
34+ /// Container name or ID.
3535 container : String ,
36- /// Override the key sequence for detaching
36+ /// Overrides the key sequence for detaching.
3737 detach_keys : Option < String > ,
38- /// Do not attach STDIN
38+ /// Doesn't attach STDIN.
3939 no_stdin : bool ,
40- /// Proxy all received signals to the process
40+ /// Proxies all received signals to the process.
4141 sig_proxy : bool ,
42- /// Command executor
42+ /// Command executor.
4343 pub executor : CommandExecutor ,
4444}
4545
4646impl AttachCommand {
47- /// Create a new attach command
47+ /// Creates a new [`AttachCommand`].
4848 ///
4949 /// # Examples
5050 ///
@@ -64,7 +64,7 @@ impl AttachCommand {
6464 }
6565 }
6666
67- /// Override the key sequence for detaching a container
67+ /// Overrides the key sequence for detaching a container.
6868 ///
6969 /// # Examples
7070 ///
@@ -80,7 +80,7 @@ impl AttachCommand {
8080 self
8181 }
8282
83- /// Do not attach STDIN
83+ /// Doesn't attach STDIN.
8484 ///
8585 /// # Examples
8686 ///
@@ -96,7 +96,7 @@ impl AttachCommand {
9696 self
9797 }
9898
99- /// Do not proxy signals
99+ /// Doesn't proxy signals.
100100 ///
101101 /// # Examples
102102 ///
@@ -112,13 +112,14 @@ impl AttachCommand {
112112 self
113113 }
114114
115- /// Execute the attach command
115+ /// Executes the attach command.
116116 ///
117117 /// # Errors
118+ ///
118119 /// Returns an error if:
119- /// - The Docker daemon is not running
120- /// - The container doesn't exist
121- /// - The container is not running
120+ /// - The Docker daemon is not running;
121+ /// - The container doesn't exist;
122+ /// - The container is not running.
122123 ///
123124 /// # Examples
124125 ///
@@ -149,6 +150,10 @@ impl AttachCommand {
149150impl DockerCommand for AttachCommand {
150151 type Output = CommandOutput ;
151152
153+ fn command_name ( ) -> & ' static str {
154+ "attach"
155+ }
156+
152157 fn executor ( & self ) -> & CommandExecutor {
153158 & self . executor
154159 }
@@ -173,10 +178,10 @@ impl DockerCommand for AttachCommand {
173178 args. push ( "--sig-proxy=false" . to_string ( ) ) ;
174179 }
175180
176- // Add container name/ID
181+ // add container name/ID
177182 args. push ( self . container . clone ( ) ) ;
178183
179- // Add raw arguments from executor
184+ // add raw arguments from executor
180185 args. extend ( self . executor . raw_args . clone ( ) ) ;
181186
182187 args
@@ -188,23 +193,23 @@ impl DockerCommand for AttachCommand {
188193 }
189194}
190195
191- /// Result from the attach command
196+ /// Result from the attach command.
192197#[ derive( Debug , Clone ) ]
193198pub struct AttachResult {
194- /// Raw command output
199+ /// Raw command output.
195200 pub output : CommandOutput ,
196- /// Container that was attached to
201+ /// Container that was attached to.
197202 pub container : String ,
198203}
199204
200205impl AttachResult {
201- /// Check if the attach was successful
206+ /// Checks if the attach was successful.
202207 #[ must_use]
203208 pub fn success ( & self ) -> bool {
204209 self . output . success
205210 }
206211
207- /// Get the container name
212+ /// Gets the container name.
208213 #[ must_use]
209214 pub fn container ( & self ) -> & str {
210215 & self . container
0 commit comments