summaryrefslogtreecommitdiffstats
path: root/examples/import.rs
blob: 7ea35bdb22a00a3cefaebc0a3d580f18d472329c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use futures::StreamExt;
use shiplift::Docker;
use std::{env, fs::File};

#[tokio::main]
async fn main() {
    let docker = Docker::new();
    let path = env::args()
        .nth(1)
        .expect("You need to specify an image path");
    let f = File::open(path).expect("Unable to open file");

    let reader = Box::from(f);

    let mut stream = docker.images().import(reader);

    while let Some(import_result) = stream.next().await {
        match import_result {
            Ok(output) => println!("{:?}", output),
            Err(e) => eprintln!("Error: {}", e),
        }
    }
}