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

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 fut = docker
        .images()
        .import(reader)
        .for_each(|output| {
            println!("{:?}", output);
            Ok(())
        })
        .map_err(|e| eprintln!("Error: {}", e));

    tokio::run(fut);
}