From a368a93e1f217cd38a0fe52456b4ab03008d75d4 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 27 Dec 2019 04:17:07 +0100 Subject: Re-export hyper::Uri as shiplift::Uri (#209) This patch removes the explicit dependency on the http crate and instead accesses the re-exported version of hyper. This should make the update process slightly easier because those versions would need to be kept in sync manually. We also re-export hyper::Uri as shiplift::Uri because it is part of the public API of shiplift::Docker. This allows users to access the Uri type without having to seperately depend on http or hyper. --- Cargo.toml | 1 - src/errors.rs | 7 +++---- src/lib.rs | 3 ++- src/transport.rs | 2 +- tests/reexported_types.rs | 4 ++++ 5 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 tests/reexported_types.rs diff --git a/Cargo.toml b/Cargo.toml index a550b43..c85ed4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ bytes = "0.4" chrono = { version = "0.4", optional = true, features = ["serde"] } flate2 = "1.0" futures = "0.1" -http = "0.1" hyper = "0.12" hyper-openssl = { version = "0.7", optional = true } hyperlocal = { version = "0.6", optional = true } diff --git a/src/errors.rs b/src/errors.rs index 85e46b8..f0f70d7 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,6 +1,5 @@ //! Representations of various client errors -use http; use hyper::{self, StatusCode}; use serde_json::Error as SerdeError; use std::{error::Error as StdError, fmt, io::Error as IoError, string::FromUtf8Error}; @@ -9,7 +8,7 @@ use std::{error::Error as StdError, fmt, io::Error as IoError, string::FromUtf8E pub enum Error { SerdeJsonError(SerdeError), Hyper(hyper::Error), - Http(http::Error), + Http(hyper::http::Error), IO(IoError), Encoding(FromUtf8Error), InvalidResponse(String), @@ -29,8 +28,8 @@ impl From for Error { } } -impl From for Error { - fn from(error: http::Error) -> Error { +impl From for Error { + fn from(error: hyper::http::Error) -> Error { Error::Http(error) } } diff --git a/src/lib.rs b/src/lib.rs index f96915a..14ed170 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,7 +46,8 @@ use crate::{ tty::TtyDecoder, }; use futures::{future::Either, Future, IntoFuture, Stream}; -use hyper::{client::HttpConnector, Body, Client, Method, Uri}; +pub use hyper::Uri; +use hyper::{client::HttpConnector, Body, Client, Method}; #[cfg(feature = "tls")] use hyper_openssl::HttpsConnector; #[cfg(feature = "unix-socket")] diff --git a/src/transport.rs b/src/transport.rs index 2887790..7cc1fb1 100644 --- a/src/transport.rs +++ b/src/transport.rs @@ -148,7 +148,7 @@ impl Transport { endpoint: &str, body: Option<(B, Mime)>, headers: Option, - f: impl FnOnce(&mut ::http::request::Builder), + f: impl FnOnce(&mut ::hyper::http::request::Builder), ) -> Result> where B: Into, diff --git a/tests/reexported_types.rs b/tests/reexported_types.rs new file mode 100644 index 0000000..7a08130 --- /dev/null +++ b/tests/reexported_types.rs @@ -0,0 +1,4 @@ +#[test] +fn can_access_uri_from_shiplift_crate() { + let _ = shiplift::Uri::default(); +} -- cgit v1.2.3