summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorKeir Lawson <keirlawson@gmail.com>2019-05-18 02:45:24 +0100
committerDoug Tangren <d.tangren@gmail.com>2019-05-17 21:45:24 -0400
commite5258c8e63f09ef7aafc7e489bb62131eb34a74f (patch)
tree83e4d91889c8f300e2316d1529de3f0971690b12 /examples
parente97bf7175ddf063788df2fa630b4dedcd19388a0 (diff)
Add import functionality (#165)
Diffstat (limited to 'examples')
-rw-r--r--examples/import.rs24
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);
+}