Stop a container with a grace period in seconds.
(
&self,
name: &str,
timeout_secs: u32,
)
| 423 | |
| 424 | /// Stop a container with a grace period in seconds. |
| 425 | pub async fn stop_container( |
| 426 | &self, |
| 427 | name: &str, |
| 428 | timeout_secs: u32, |
| 429 | ) -> Result<(), PodmanApiError> { |
| 430 | validate_name(name)?; |
| 431 | let http_timeout = Duration::from_secs(u64::from(timeout_secs) + 5); |
| 432 | let (status, bytes) = self |
| 433 | .request( |
| 434 | hyper::Method::POST, |
| 435 | &format!("/libpod/containers/{name}/stop?timeout={timeout_secs}"), |
| 436 | None, |
| 437 | http_timeout, |
| 438 | ) |
| 439 | .await?; |
| 440 | let code = status.as_u16(); |
| 441 | if status.is_success() || code == 304 { |
| 442 | Ok(()) |
| 443 | } else { |
| 444 | Err(error_from_response(code, &bytes)) |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | /// Force-remove a container and its anonymous volumes. |
| 449 | pub async fn remove_container(&self, name: &str) -> Result<(), PodmanApiError> { |
no test coverage detected