diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/import.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/import.rs b/examples/import.rs new file mode 100644 index 0000000..20c61e6 --- /dev/null +++ b/examples/import.rs @@ -0,0 +1,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); +} |