diff options
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | examples/containercreate.rs | 18 | ||||
-rw-r--r-- | examples/containerdelete.rs | 19 | ||||
-rw-r--r-- | examples/containerexec.rs | 29 | ||||
-rw-r--r-- | examples/containerinspect.rs | 16 | ||||
-rw-r--r-- | examples/containers.rs | 16 | ||||
-rw-r--r-- | examples/events.rs | 14 | ||||
-rw-r--r-- | examples/export.rs | 38 | ||||
-rw-r--r-- | examples/imagebuild.rs | 21 | ||||
-rw-r--r-- | examples/imagedelete.rs | 22 | ||||
-rw-r--r-- | examples/imageinspect.rs | 16 | ||||
-rw-r--r-- | examples/imagepull.rs | 21 | ||||
-rw-r--r-- | examples/images.rs | 20 | ||||
-rw-r--r-- | examples/info.rs | 9 | ||||
-rw-r--r-- | examples/logs.rs | 29 | ||||
-rw-r--r-- | examples/networkconnect.rs | 12 | ||||
-rw-r--r-- | examples/networkcreate.rs | 26 | ||||
-rw-r--r-- | examples/networkdelete.rs | 16 | ||||
-rw-r--r-- | examples/networkdisconnect.rs | 12 | ||||
-rw-r--r-- | examples/networkinspect.rs | 16 | ||||
-rw-r--r-- | examples/networks.rs | 15 | ||||
-rw-r--r-- | examples/stats.rs | 20 | ||||
-rw-r--r-- | examples/top.rs | 20 | ||||
-rw-r--r-- | src/builder.rs | 33 | ||||
-rw-r--r-- | src/errors.rs | 7 | ||||
-rw-r--r-- | src/lib.rs | 434 | ||||
-rw-r--r-- | src/read.rs | 103 | ||||
-rw-r--r-- | src/rep.rs | 9 | ||||
-rw-r--r-- | src/transport.rs | 202 | ||||
-rw-r--r-- | src/tty.rs | 151 |
30 files changed, 861 insertions, 507 deletions
@@ -12,7 +12,9 @@ license = "MIT" [dependencies] byteorder = "1" +bytes = "0.4" flate2 = "1" +futures = "0.1" http = "0.1" hyper = "0.12" hyper-openssl = "0.6" @@ -22,6 +24,8 @@ mime = "0.3" openssl = "0.10" tar = "0.4" tokio = "0.1" +tokio-codec = "0.1" +tokio-io = "0.1" url = "1.7" serde = "1" serde_derive = "1" diff --git a/examples/containercreate.rs b/examples/containercreate.rs index 71307b8..f5baf39 100644 --- a/examples/containercreate.rs +++ b/examples/containercreate.rs @@ -1,15 +1,19 @@ extern crate shiplift; +extern crate tokio; use shiplift::{ContainerOptions, Docker}; use std::env; +use tokio::prelude::Future; fn main() { let docker = Docker::new(); - let containers = docker.containers(); - if let Some(image) = env::args().nth(1) { - let info = containers - .create(&ContainerOptions::builder(image.as_ref()).build()) - .unwrap(); - println!("{:?}", info); - } + let image = env::args() + .nth(1) + .expect("You need to specify an image name"); + let fut = docker + .containers() + .create(&ContainerOptions::builder(image.as_ref()).build()) + .map(|info| println!("{:?}", info)) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); } diff --git a/examples/containerdelete.rs b/examples/containerdelete.rs new file mode 100644 index 0000000..cc2e9b7 --- /dev/null +++ b/examples/containerdelete.rs @@ -0,0 +1,19 @@ +extern crate shiplift; +extern crate tokio; + +use shiplift::Docker; +use std::env; +use tokio::prelude::Future; + +fn main() { + let docker = Docker::new(); + let id = env::args() + .nth(1) + .expect("You need to specify an container id"); + let fut = docker + .containers() + .get(&id) + .delete() + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); +} diff --git a/examples/containerexec.rs b/examples/containerexec.rs index e10d245..0b3575b 100644 --- a/examples/containerexec.rs +++ b/examples/containerexec.rs @@ -1,10 +1,16 @@ extern crate shiplift; +extern crate tokio; -use shiplift::{Docker, ExecContainerOptions}; +use shiplift::{tty::StreamType, Docker, ExecContainerOptions}; use std::env; +use tokio::prelude::{Future, Stream}; fn main() { let docker = Docker::new(); + let id = env::args() + .nth(1) + .expect("You need to specify a container id"); + let options = ExecContainerOptions::builder() .cmd(vec![ "bash", @@ -15,13 +21,18 @@ fn main() { .attach_stdout(true) .attach_stderr(true) .build(); - if let Some(id) = env::args().nth(1) { - match docker.containers().get(&id).exec(&options) { - Ok(res) => { - println!("Stdout: {}", res.stdout); - println!("Stderr: {}", res.stderr); + let fut = docker + .containers() + .get(&id) + .exec(&options) + .for_each(|line| { + match line.stream_type { + StreamType::StdOut => println!("Stdout: {}", line.data), + StreamType::StdErr => eprintln!("Stderr: {}", line.data), } - Err(err) => println!("An error occured: {:?}", err), - } - } + Ok(()) + }) + .map_err(|e| eprintln!("Error: {}", e)); + + tokio::run(fut); } diff --git a/examples/containerinspect.rs b/examples/containerinspect.rs index a34b5f3..ebd37ef 100644 --- a/examples/containerinspect.rs +++ b/examples/containerinspect.rs @@ -1,12 +1,20 @@ extern crate shiplift; +extern crate tokio; use shiplift::Docker; use std::env; +use tokio::prelude::Future; fn main() { let docker = Docker::new(); - if let Some(id) = env::args().nth(1) { - let container = docker.containers().get(&id).inspect().unwrap(); - println!("{:?}", container); - } + let id = env::args() + .nth(1) + .expect("Usage: cargo run --example containerinspect -- <container>"); + let fut = docker + .containers() + .get(&id) + .inspect() + .map(|container| println!("{:#?}", container)) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); } diff --git a/examples/containers.rs b/examples/containers.rs index 27a5d20..71da705 100644 --- a/examples/containers.rs +++ b/examples/containers.rs @@ -1,12 +1,22 @@ extern crate env_logger; extern crate shiplift; +extern crate tokio; use shiplift::Docker; +use tokio::prelude::Future; fn main() { env_logger::init(); let docker = Docker::new(); - for c in docker.containers().list(&Default::default()).unwrap() { - println!("container -> {:?}", c) - } + let fut = docker + .containers() + .list(&Default::default()) + .map(|containers| { + for c in containers { + println!("container -> {:#?}", c) + } + }) + .map_err(|e| eprintln!("Error: {}", e)); + + tokio::run(fut); } diff --git a/examples/events.rs b/examples/events.rs index f1518d3..ced2f29 100644 --- a/examples/events.rs +++ b/examples/events.rs @@ -1,11 +1,19 @@ extern crate shiplift; +extern crate tokio; use shiplift::Docker; +use tokio::prelude::{Future, Stream}; fn main() { let docker = Docker::new(); println!("listening for events"); - for e in docker.events(&Default::default()).unwrap() { - println!("event -> {:?}", e) - } + + let fut = docker + .events(&Default::default()) + .for_each(|e| { + println!("event -> {:?}", e); + Ok(()) + }) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); } diff --git a/examples/export.rs b/examples/export.rs index b12e2f8..b8d8eaf 100644 --- a/examples/export.rs +++ b/examples/export.rs @@ -1,22 +1,32 @@ extern crate shiplift; +extern crate tokio; -use shiplift::Docker; +use shiplift::{errors::Error, Docker}; use std::env; use std::fs::OpenOptions; -use std::io::copy; +use std::io::Write; +use tokio::prelude::{Future, Stream}; fn main() { let docker = Docker::new(); - if let Some(id) = env::args().nth(1) { - let mut export = OpenOptions::new() - .write(true) - .create(true) - .open(format!("{}.tgz", &id)) - .unwrap(); - let images = docker.images(); - let mut exported = images.get(&id).export().unwrap(); - println!("copying"); - copy(&mut exported, &mut export).unwrap(); - println!("copied"); - } + let id = env::args().nth(1).expect("You need to specify an image id"); + + let mut export_file = OpenOptions::new() + .write(true) + .create(true) + .open(format!("{}.tar", &id)) + .unwrap(); + let images = docker.images(); + let fut = images + .get(&id) + .export() + .for_each(move |bytes| { + export_file + .write(&bytes[..]) + .map(|n| println!("copied {} bytes", n)) + .map_err(Error::IO) + }) + .map_err(|e| eprintln!("Error: {}", e)); + + tokio::run(fut) } diff --git a/examples/imagebuild.rs b/examples/imagebuild.rs index 788634e..4b67219 100644 --- a/examples/imagebuild.rs +++ b/examples/imagebuild.rs @@ -1,17 +1,22 @@ extern crate shiplift; +extern crate tokio; use shiplift::{BuildOptions, Docker}; use std::env; +use tokio::prelude::{Future, Stream}; fn main() { let docker = Docker::new(); - if let Some(path) = env::args().nth(1) { - let image = docker - .images() - .build(&BuildOptions::builder(path).tag("shiplift_test").build()) - .unwrap(); - for output in image { + let path = env::args().nth(1).expect("You need to specify a path"); + + let fut = docker + .images() + .build(&BuildOptions::builder(path).tag("shiplift_test").build()) + .for_each(|output| { println!("{:?}", output); - } - } + Ok(()) + }) + .map_err(|e| eprintln!("Error: {}", e)); + + tokio::run(fut); } diff --git a/examples/imagedelete.rs b/examples/imagedelete.rs index e239865..5e507a2 100644 --- a/examples/imagedelete.rs +++ b/examples/imagedelete.rs @@ -1,14 +1,24 @@ extern crate shiplift; +extern crate tokio; use shiplift::Docker; use std::env; +use tokio::prelude::Future; fn main() { let docker = Docker::new(); - if let Some(img) = env::args().nth(1) { - let image = docker.images().get(&img[..]).delete().unwrap(); - for status in image { - println!("{:?}", status); - } - } + let img = env::args() + .nth(1) + .expect("You need to specify an image name"); + let fut = docker + .images() + .get(&img[..]) + .delete() + .map(|statuses| { + for status in statuses { + println!("{:?}", status); + } + }) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); } diff --git a/examples/imageinspect.rs b/examples/imageinspect.rs index 50144f0..0cd8450 100644 --- a/examples/imageinspect.rs +++ b/examples/imageinspect.rs @@ -1,12 +1,20 @@ extern crate shiplift; +extern crate tokio; use shiplift::Docker; use std::env; +use tokio::prelude::Future; fn main() { let docker = Docker::new(); - if let Some(id) = env::args().nth(1) { - let image = docker.images().get(&id).inspect().unwrap(); - println!("{:?}", image); - } + let id = env::args() + .nth(1) + .expect("Usage: cargo run --example imageinspect -- <image>"); + let fut = docker + .images() + .get(&id) + .inspect() + .map(|image| println!("{:#?}", image)) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); } diff --git a/examples/imagepull.rs b/examples/imagepull.rs index d460a41..1039080 100644 --- a/examples/imagepull.rs +++ b/examples/imagepull.rs @@ -1,17 +1,22 @@ extern crate shiplift; +extern crate tokio; use shiplift::{Docker, PullOptions}; use std::env; +use tokio::prelude::{Future, Stream}; fn main() { let docker = Docker::new(); - if let Some(img) = env::args().nth(1) { - let image = docker - .images() - .pull(&PullOptions::builder().image(img).build()) - .unwrap(); - for output in image { + let img = env::args() + .nth(1) + .expect("You need to specify an image name"); + let fut = docker + .images() + .pull(&PullOptions::builder().image(img).build()) + .for_each(|output| { println!("{:?}", output); - } - } + Ok(()) + }) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); } diff --git a/examples/images.rs b/examples/images.rs index 195ea06..b3e80a8 100644 --- a/examples/images.rs +++ b/examples/images.rs @@ -1,10 +1,20 @@ extern crate shiplift; +extern crate tokio; + +use shiplift::Docker; +use tokio::prelude::Future; fn main() { - let docker = shiplift::Docker::new(); - let images = docker.images().list(&Default::default()).unwrap(); + let docker = Docker::new(); println!("docker images in stock"); - for i in images { - println!("{:?}", i.repo_tags); - } + let fut = docker + .images() + .list(&Default::default()) + .map(|images| { + for i in images { + println!("{:?}", i.repo_tags); + } + }) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); } diff --git a/examples/info.rs b/examples/info.rs index 372b603..b608818 100644 --- a/examples/info.rs +++ b/examples/info.rs @@ -1,8 +1,15 @@ extern crate shiplift; +extern crate tokio; use shiplift::Docker; +use tokio::prelude::Future; fn main() { let docker = Docker::new(); - println!("info {:?}", docker.info().unwrap()); + tokio::run( + docker + .info() + .map(|info| println!("info {:?}", info)) + .map_err(|e| eprintln!("Error: {}", e)), + ); } diff --git a/examples/logs.rs b/examples/logs.rs index 18e68d0..b35b0a3 100644 --- a/examples/logs.rs +++ b/examples/logs.rs @@ -1,16 +1,27 @@ extern crate shiplift; +extern crate tokio; -use shiplift::{Docker, LogsOptions}; +use shiplift::{tty::StreamType, Docker, LogsOptions}; use std::env; +use tokio::prelude::{Future, Stream}; fn main() { let docker = Docker::new(); - if let Some(id) = env::args().nth(1) { - let mut logs = docker - .containers() - .get(&id) - .logs(&LogsOptions::builder().stdout(true).build()) - .unwrap(); - std::io::copy(&mut logs, &mut std::io::stdout()).unwrap(); - } + let id = env::args() + .nth(1) + .expect("You need to specify a container id"); + let fut = docker + .containers() + .get(&id) + .logs(&LogsOptions::builder().stdout(true).stderr(true).build()) + .for_each(|line| { + match line.stream_type { + StreamType::StdOut => println!("Stdout: {}", line.data), + StreamType::StdErr => eprintln!("Stderr: {}", line.data), + } + Ok(()) + }) + .map_err(|e| eprintln!("Error: {}", e)); + + tokio::run(fut); } diff --git a/examples/networkconnect.rs b/examples/networkconnect.rs index e203e18..86a2ac1 100644 --- a/examples/networkconnect.rs +++ b/examples/networkconnect.rs @@ -1,18 +1,22 @@ extern crate shiplift; +extern crate tokio; use shiplift::{ContainerConnectionOptions, Docker}; use std::env; +use tokio::prelude::Future; fn main() { let docker = Docker::new(); let networks = docker.networks(); match (env::args().nth(1), env::args().nth(2)) { - (Some(container_id), Some(network_id)) => println!( - "{:?}", - networks + (Some(container_id), Some(network_id)) => { + let fut = networks .get(&network_id) .connect(&ContainerConnectionOptions::new(&container_id)) - ), + .map(|v| println!("{:?}", v)) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); + } _ => eprintln!("please provide a container_id and network_id"), } } diff --git a/examples/networkcreate.rs b/examples/networkcreate.rs index e64d826..a7b7662 100644 --- a/examples/networkcreate.rs +++ b/examples/networkcreate.rs @@ -1,19 +1,23 @@ extern crate shiplift; +extern crate tokio; use shiplift::{Docker, NetworkCreateOptions}; use std::env; +use tokio::prelude::Future; fn main() { let docker = Docker::new(); - let networks = docker.networks(); - if let Some(network_name) = env::args().nth(1) { - let info = networks - .create( - &NetworkCreateOptions::builder(network_name.as_ref()) - .driver("bridge") - .build(), - ) - .unwrap(); - println!("{:?}", info); - } + let network_name = env::args() + .nth(1) + .expect("You need to specify a network name"); + let fut = docker + .networks() + .create( + &NetworkCreateOptions::builder(network_name.as_ref()) + .driver("bridge") + .build(), + ) + .map(|info| println!("{:?}", info)) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); } diff --git a/examples/networkdelete.rs b/examples/networkdelete.rs index 1ce4c4d..8f1cdca 100644 --- a/examples/networkdelete.rs +++ b/examples/networkdelete.rs @@ -1,11 +1,21 @@ extern crate shiplift; +extern crate tokio; use shiplift::Docker; use std::env; +use tokio::prelude::Future; fn main() { let docker = Docker::new(); - if let Some(id) = env::args().nth(1) { - println!("{:?}", docker.networks().get(&id).delete()); - } + let id = env::args() + .nth(1) + .expect("You need to specify a network id"); + let fut = docker + .networks() + .get(&id) + .delete() + .map(|network| println!("{:?}", network)) + .map_err(|e| eprintln!("Error: {}", e)); + + tokio::run(fut); } diff --git a/examples/networkdisconnect.rs b/examples/networkdisconnect.rs index 9676dc9..9c529a1 100644 --- a/examples/networkdisconnect.rs +++ b/examples/networkdisconnect.rs @@ -1,18 +1,22 @@ extern crate shiplift; +extern crate tokio; use shiplift::{ContainerConnectionOptions, Docker}; use std::env; +use tokio::prelude::Future; fn main() { let docker = Docker::new(); let networks = docker.networks(); match (env::args().nth(1), env::args().nth(2)) { - (Some(container_id), Some(network_id)) => println!( - "{:?}", - networks + (Some(container_id), Some(network_id)) => { + let fut = networks .get(&network_id) .disconnect(&ContainerConnectionOptions::new(&container_id)) - ), + .map(|v| println!("{:?}", v)) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); + } _ => eprintln!("please provide a container_id and network_id"), } } diff --git a/examples/networkinspect.rs b/examples/networkinspect.rs index f88b3c2..37992a5 100644 --- a/examples/networkinspect.rs +++ b/examples/networkinspect.rs @@ -1,12 +1,20 @@ extern crate shiplift; +extern crate tokio; use shiplift::Docker; use std::env; +use tokio::prelude::Future; fn main() { let docker = Docker::new(); - if let Some(id) = env::args().nth(1) { - let network = docker.networks().get(&id).inspect().unwrap(); - println!("{:?}", network); - } + let id = env::args() + .nth(1) + .expect("You need to specify a network id"); + let fut = docker + .networks() + .get(&id) + .inspect() + .map(|network| println!("{:#?}", network)) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); } diff --git a/examples/networks.rs b/examples/networks.rs index 03da617..57cd566 100644 --- a/examples/networks.rs +++ b/examples/networks.rs @@ -1,12 +1,21 @@ extern crate env_logger; extern crate shiplift; +extern crate tokio; use shiplift::Docker; +use tokio::prelude::Future; fn main() { env_logger::init(); let docker = Docker::new(); - for c in docker.networks().list(&Default::default()).unwrap() { - println!("network -> {:?}", c) - } + let fut = docker + .networks() + .list(&Default::default()) + .map(|networks| { + for network in networks { + println!("network -> {:#?}", network); + } + }) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); } diff --git a/examples/stats.rs b/examples/stats.rs index 9a0f38d..f136326 100644 --- a/examples/stats.rs +++ b/examples/stats.rs @@ -1,15 +1,23 @@ extern crate shiplift; +extern crate tokio; use shiplift::Docker; use std::env; +use tokio::prelude::{Future, Stream}; fn main() { let docker = Docker::new(); let containers = docker.containers(); - if let Some(id) = env::args().nth(1) { - let stats = containers.get(&id).stats(); - for s in stats.unwrap() { - println!("{:?}", s); - } - } + let id = env::args() + .nth(1) + .expect("Usage: cargo run --example stats -- <container>"); + let fut = containers + .get(&id) + .stats() + .for_each(|stat| { + println!("{:?}", stat); + Ok(()) + }) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); } diff --git a/examples/top.rs b/examples/top.rs index 79a7f07..1bdf6ca 100644 --- a/examples/top.rs +++ b/examples/top.rs @@ -1,16 +1,20 @@ extern crate shiplift; +extern crate tokio; use shiplift::Docker; use std::env; +use tokio::prelude::Future; fn main() { let docker = Docker::new(); - if let Some(id) = env::args().nth(1) { - let top = docker - .containers() - .get(&id) - .top(Default::default()) - .unwrap(); - println!("{:?}", top); - } + let id = env::args() + .nth(1) + .expect("Usage: cargo run --example top -- <container>"); + let fut = docker + .containers() + .get(&id) + .top(Default::default()) + .map(|top| println!("{:#?}", top)) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); } diff --git a/src/builder.rs b/src/builder.rs index 05576f4..27a92e4 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -373,7 +373,7 @@ impl ContainerOptions { /// serialize options as a string. returns None if no options are defined pub fn serialize(&self) -> Result<String> { - Ok(serde_json::to_string(&self.to_json())?) + serde_json::to_string(&self.to_json()).map_err(Error::from) } fn to_json(&self) -> Value { @@ -600,7 +600,23 @@ impl ExecContainerOptions { /// serialize options as a string. returns None if no options are defined pub fn serialize(&self) -> Result<String> { - Ok(serde_json::to_string(self)?) + let mut body = serde_json::Map::new(); + + for (k, v) in &self.params { + body.insert( + k.to_string(), + serde_json::to_value(v).map_err(Error::SerdeJsonError)?, + ); + } + + for (k, v) in &self.params_bool { + body.insert( + k.to_string(), + serde_json::to_value(v).map_err(Error::SerdeJsonError)?, + ); + } + + serde_json::to_string(&body).map_err(Error::from) } } @@ -873,7 +889,7 @@ impl LogsOptionsBuilder { self } - /// how_many can either by "all" or a to_string() of the number + /// how_many can either be "all" or a to_string() of the number pub fn tail( &mut self, how_many: &str, @@ -1067,15 +1083,22 @@ impl NetworkCreateOptions { NetworkCreateOptionsBuilder::new(name) } + fn to_json(&self) -> Value { + let mut body = serde_json::Map::new(); + self.parse_from(&self.params, &mut body); + self.parse_from(&self.params_hash, &mut body); + Value::Object(body) + } + /// serialize options as a string. returns None if no options are defined pub fn serialize(&self) -> Result<String> { - serde_json::to_string(self).map_err(Error::from) + serde_json::to_string(&self.to_json()).map_err(Error::from) } pub fn parse_from<'a, K, V>( &self, params: &'a HashMap<K, V>, - body: &mut BTreeMap<String, Value>, + body: &mut serde_json::Map<String, Value>, ) where &'a HashMap<K, V>: IntoIterator, K: ToString + Eq + Hash, diff --git a/src/errors.rs b/src/errors.rs index 5af8c44..36be662 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -6,6 +6,7 @@ use serde_json::Error as SerdeError; use std::error::Error as StdError; use std::fmt; use std::io::Error as IoError; +use std::string::FromUtf8Error; #[derive(Debug)] pub enum Error { @@ -13,6 +14,8 @@ pub enum Error { Hyper(hyper::Error), Http(http::Error), IO(IoError), + Encoding(FromUtf8Error), + InvalidResponse(String), Fault { code: StatusCode, message: String }, } @@ -51,6 +54,10 @@ impl fmt::Display for Error { Error::Http(ref err) => err.fmt(f), Error::Hyper(ref err) => err.fmt(f), Error::IO(ref err) => err.fmt(f), + Error::Encoding(ref err) => err.fmt(f), + Error::InvalidResponse(ref cause) => { + write!(f, "Response doesn't have the expected format: {}", cause) + } Error::Fault { code, .. } => write!(f, "{}", code), } } @@ -4,19 +4,27 @@ //! //! ```no_run //! extern crate shiplift; +//! extern crate tokio; +//! +//! use tokio::prelude::Future; //! //! let docker = shiplift::Docker::new(); -//! let images = docker.images().list(&Default::default()).unwrap(); -//! println!("docker images in stock"); -//! for i in images { -//! println!("{:?}", i.repo_tags); -//! } +//! let fut = docker.images().list(&Default::default()).map(|images| { +//! println!("docker images in stock"); +//! for i in images { +//! println!("{:?}", i.repo_tags); +//! } +//! }).map_err(|e| eprintln!("Something bad happened! {}", e)); +//! +//! tokio::run(fut); //! ``` #[macro_use] extern crate log; extern crate byteorder; +extern crate bytes; extern crate flate2; +extern crate futures; extern crate http; extern crate hyper; extern crate hyper_openssl; @@ -32,9 +40,12 @@ extern crate serde; #[macro_use] extern crate serde_json; extern crate tokio; +extern crate tokio_codec; +extern crate tokio_io; pub mod builder; pub mod errors; +pub mod read; pub mod rep; pub mod transport; pub mod tty; @@ -47,6 +58,7 @@ pub use builder::{ LogsOptions, NetworkCreateOptions, NetworkListOptions, PullOptions, RmContainerOptions, }; pub use |