diff options
author | Antoine Büsch <antoine.busch@gmail.com> | 2018-11-14 20:36:14 +1100 |
---|---|---|
committer | doug tangren <d.tangren@gmail.com> | 2018-11-14 18:36:14 +0900 |
commit | 79d65c286025c551a775c0964d168e6feb4b3409 (patch) | |
tree | 34b49a0f97f6f851f47711be1cad0c002b8b78f7 /src/errors.rs | |
parent | 29bd95b42cd2b3c364f0be1f3e07e4b654e0ccf3 (diff) |
Async api (#128)
* Refactored Transport for better async use
Still a bit rough, but it now builds a big future using combinators. It
still does one `Runtime::block_on()` to keep the existing API, but this
is a first up before making the whole API async.
* Migrate most APIs to be Future-based
I still need to finish a few of the more tricky ones that I've commented
out for now, but most of it compiles and some examples work. In
particular, `Docker::stats()` now properly returns an async stream of
stats.
* Fix events and containerinspect examples
* Fix imageinspect, images, info and top examples
* Fix containercreate, imagedelete and imagepull examples
* Fix more examples
* Add back debug statement in Transport::request
* De-glob imports in examples
* Remove unused imports in examples
* Fix NetworkCreateOptions serialization
* Add back error message extraction in Transport
* Fix Container::create serialization of options
* Add containerdelete example
* Simplify result
* Fix some error handling to remove unwrap()
* Fix Image::export()
* Fix imagebuild example
* Add adapter from Stream of Chunks to AsyncRead
Having an `AsyncRead` is required to be able to use the `FramedRead` and
`Decoder` stuff from tokio_codec. This code is "borrowed" from
https:/github.com/ferristseng/rust-ipfs-api though should probably be
moved to its own crate or to tokio_codec.
* Fix Container::logs()
It now properly demuxes stdout/stderr, and returns a `Stream<Item =
TtyLine>`.
* Fix Container::export()
* Use LineCodec for streaming JSON
Although in my limited testing it seemed to work fine, there is no
guarantee that 1 chunk == 1 piece of valid JSON. However, each JSON
structure seems to be serialized on one line, so use LineCodec to turn
the body into a stream of lines, then deserialize over this.
* Fix serialization of ExecContainerOptions
* Fix Container::exec() (kind of...)
* Simplify deserialisation in Image::delete()
* Small clean-ups
* More clean ups
* Fix rustdoc + remove extraneous "extern crate"
* Fix doc example
* Fix formatting
Diffstat (limited to 'src/errors.rs')
-rw-r--r-- | src/errors.rs | 7 |
1 files changed, 7 insertions, 0 deletions
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), } } |