summaryrefslogtreecommitdiffstats
path: root/examples/stats.rs
blob: 063f5026392c5c5e514122332263fbc7371f2145 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//  cargo run --example stats -- <container>
use futures::StreamExt;
use shiplift::Docker;
use std::env;

#[tokio::main]
async fn main() {
    let docker = Docker::new();
    let containers = docker.containers();
    let id = env::args()
        .nth(1)
        .expect("Usage: cargo run --example stats -- <container>");

    while let Some(result) = containers.get(&id).stats().next().await {
        match result {
            Ok(stat) => println!("{:?}", stat),
            Err(e) => eprintln!("Error: {}", e),
        }
    }
}