pub async fn wait_container<T>(&self, id: T, condition: WaitCondition) -> Result<WaitStatus, DockerError>
        where T: Into<String>
    {
        let uri = self.make_uri(format!("/containers/{}/wait?condition={}", id.into(), condition.to_string()));
        let request = Request::post(uri)
            .body(hyper::Body::empty())
            .unwrap();

        self.execute_async(request).await
            .and_then(|response| {
                match response.status {
                    200 => Ok(json::from_str(response.body_as_string().as_str()).unwrap()),
                    404 => Err(DockerError::NotFound(json::from_str(response.body_as_string().as_str()).unwrap())),
                    500 => Err(DockerError::ServerError(json::from_str(response.body_as_string().as_str()).unwrap())),
                    _ => Err(DockerError::UnknownStatus),
                }
            })
    }
/// Wait for a container
///
/// Block until a container stops, then returns the exit code.
///
/// # Arguments
/// `id` - ID or name of the container.
/// `condition` - Wait until a container state reaches the given condition, either 'not-running' (default), 'next-exit', or 'removed'.
///
/// # Examples
///
/// ```rust
/// # use docker_client::{DockerClient, DockerError};
/// # use docker_client::container::WaitCondition;
/// fn main() {
///    let client = DockerClient::new();
///
///     match client.wait_container("test-container", WaitCondition::NotRunning) {
///         Ok(status) => { println!("Status: {:?}", status); }
///         Err(e) => { println!("Error: {:?}", e); }
///     }
///
/// }
/// ```
Wait for a container
Block until a container stops, then returns the exit code.
Wait for a container Block until a container stops then returns the exit code .
pub async fn wait_container<T>(&self, id: T, condition: WaitCondition) -> Result<WaitStatus, DockerError>
        where T: Into<String>
    {
        let uri = self.make_uri(format!("/containers/{}/wait?condition={}", id.into(), condition.to_string()));
        let request = Request::post(uri)
            .body(hyper::Body::empty())
            .unwrap();
        self.execute_async(request).await
            .and_then(|response| {
                match response.status {
                    200 => Ok(json::from_str(response.body_as_string().as_str()).unwrap()),
                    404 => Err(DockerError::NotFound(json::from_str(response.body_as_string().as_str()).unwrap())),
                    500 => Err(DockerError::ServerError(json::from_str(response.body_as_string().as_str()).unwrap())),
                    _ => Err(DockerError::UnknownStatus),
                }
            })
    }
pub async fn wait_container < T > ( & self , id : T , condition : WaitCondition ) -> Result < WaitStatus , DockerError > where T : Into < String > { let uri = self . make_uri ( format ! ( " " id into ( ) condition to_string ( ) ) ) ; let request = Request :: post ( uri ) . body ( hyper :: Body :: empty ( ) ) . unwrap ( ) ; self . execute_async ( request ) . await . and_then ( | response | { match response . status { 200 => Ok ( json :: from_str ( response . body_as_string ( ) . as_str ( ) ) . unwrap ( ) ) , 404 => Err ( DockerError :: NotFound ( json :: from_str ( response . body_as_string ( ) . as_str ( ) ) . unwrap ( ) ) ) , 500 => Err ( DockerError :: ServerError ( json :: from_str ( response . body_as_string ( ) . as_str ( ) ) . unwrap ( ) ) ) , _ => Err ( DockerError :: UnknownStatus ) , } } ) }
Wait for a container
Block until a container stops, then returns the exit code.
Wait for a container Block until a container stops then returns the exit code .
&self
id
T
condition
WaitCondition
&self
id
T
condition
WaitCondition
examples
None
use docker_client::{dockerclient, dockererror};
None
use docker_client::container::waitcondition;
fn main() {
let client = DockerClient::new().

match client.wait_container("test-container", WaitCondition::NotRunning) {
Ok(status) => { println!("Status: {:?}", status); }
Err(e) => { println!("Error: {:?}", e); }
}


fn main () { let client = DockerClient :: new () . match client . wait_container ( " test - container " WaitCondition :: NotRunning ) { Ok ( status ) = > { println! ( " Status : { : ? } " status ) ; } Err ( e ) = > { println! ( " Error : { : ? } " e ) ; } }