diff --git a/Cargo.lock b/Cargo.lock index c564a732b..8916d14a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,7 +125,6 @@ dependencies = [ "bytes 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "conduit-proxy-controller-grpc 0.3.0", "conduit-proxy-router 0.3.0", - "convert 0.3.0", "deflate 0.7.18 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -174,7 +173,6 @@ name = "conduit-proxy-controller-grpc" version = "0.3.0" dependencies = [ "bytes 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "convert 0.3.0", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "h2 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -196,10 +194,6 @@ dependencies = [ "tower-service 0.1.0 (git+https://github.com/tower-rs/tower)", ] -[[package]] -name = "convert" -version = "0.3.0" - [[package]] name = "crc" version = "1.7.0" diff --git a/Cargo.toml b/Cargo.toml index cb9ddc34d..c356b609e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,6 @@ [workspace] members = [ "proxy", - "proxy/convert", "proxy/controller-grpc", "proxy/futures-mpsc-lossy", "proxy/router", diff --git a/proxy/Cargo.toml b/proxy/Cargo.toml index a9d7d2421..f8328ccc1 100644 --- a/proxy/Cargo.toml +++ b/proxy/Cargo.toml @@ -10,7 +10,6 @@ default = ["flaky_tests"] flaky_tests = [] [dependencies] -convert = { path = "./convert" } conduit-proxy-controller-grpc = { path = "./controller-grpc" } futures-mpsc-lossy = { path = "./futures-mpsc-lossy" } conduit-proxy-router = { path = "./router" } diff --git a/proxy/convert/Cargo.toml b/proxy/convert/Cargo.toml deleted file mode 100644 index 16ae10e3e..000000000 --- a/proxy/convert/Cargo.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -name = "convert" -version = "0.3.0" -publish = false diff --git a/proxy/src/control/observe.rs b/proxy/src/control/observe.rs index 0e7b00d50..c48051acd 100644 --- a/proxy/src/control/observe.rs +++ b/proxy/src/control/observe.rs @@ -141,7 +141,7 @@ impl Stream for TapEvents { _ => continue, } - if let Ok(te) = (&ev).try_into() { + if let Ok(te) = TapEvent::try_from(&ev) { // TODO Do limit checks here. return Ok(Some(te).into()); } diff --git a/proxy/convert/src/lib.rs b/proxy/src/convert.rs similarity index 52% rename from proxy/convert/src/lib.rs rename to proxy/src/convert.rs index 89d698d63..34c42217c 100644 --- a/proxy/convert/src/lib.rs +++ b/proxy/src/convert.rs @@ -15,25 +15,3 @@ pub trait TryFrom: Sized { #[doc(hidden)] fn try_from(t: T) -> Result; } - -/// Private trait for generic methods with fallible conversions. -/// -/// This trait is similar to the `TryInto` trait proposed in the standard -/// library, and should be removed when `TryInto` is stabilized. -pub trait TryInto: Sized { - type Err; - - #[doc(hidden)] - fn try_into(self) -> Result; -} - -impl TryInto for T -where - U: TryFrom, -{ - type Err = U::Err; - - fn try_into(self) -> Result { - U::try_from(self) - } -} diff --git a/proxy/src/lib.rs b/proxy/src/lib.rs index 5cdfe34fe..d2460ac39 100644 --- a/proxy/src/lib.rs +++ b/proxy/src/lib.rs @@ -4,7 +4,6 @@ extern crate bytes; extern crate conduit_proxy_controller_grpc; -extern crate convert; extern crate env_logger; extern crate deflate; #[macro_use] @@ -69,6 +68,7 @@ mod bind; pub mod config; mod connection; pub mod control; +pub mod convert; pub mod ctx; mod dns; mod drain; diff --git a/proxy/src/telemetry/tap/match_.rs b/proxy/src/telemetry/tap/match_.rs index 15e2746e5..cb9057b56 100644 --- a/proxy/src/telemetry/tap/match_.rs +++ b/proxy/src/telemetry/tap/match_.rs @@ -9,7 +9,7 @@ use ipnet::{Contains, Ipv4Net, Ipv6Net}; use super::Event; use conduit_proxy_controller_grpc::common::ip_address; use conduit_proxy_controller_grpc::tap::observe_request; -use convert::*; +use convert::TryFrom; use ctx; #[derive(Clone, Debug)] @@ -358,7 +358,7 @@ impl<'a> TryFrom<&'a observe_request::match_::Http> for HttpMatch { .as_ref() .ok_or_else(|| InvalidMatch::Empty) .and_then(|s| { - s.try_into() + s.try_to_string() .map(HttpMatch::Scheme) .map_err(|_| InvalidMatch::InvalidScheme) }), @@ -367,7 +367,7 @@ impl<'a> TryFrom<&'a observe_request::match_::Http> for HttpMatch { .as_ref() .ok_or_else(|| InvalidMatch::Empty) .and_then(|m| { - m.try_into() + m.try_as_http() .map(HttpMatch::Method) .map_err(|_| InvalidMatch::InvalidHttpMethod) }), diff --git a/proxy/tests/support/mod.rs b/proxy/tests/support/mod.rs index c42de1248..89d9705a9 100644 --- a/proxy/tests/support/mod.rs +++ b/proxy/tests/support/mod.rs @@ -8,7 +8,6 @@ pub extern crate bytes; pub extern crate conduit_proxy_controller_grpc; extern crate conduit_proxy; -pub extern crate convert; extern crate futures; extern crate h2; pub extern crate http;