proxy: Convert `convert` from crate to module (#1115)
In e2093e3, we created a `convert` crate when refactoring the proxy's gRPC bindings into a dedicated crate. It's not really necessary to handle `convert` as a crate, given that it holds a single 39-line file that's mostly comments. It's possible to "vendor" this file in the proxy, and controller-grpc crate doesn't even need this trait (in fact, the proxy probably doesn't either).
This commit is contained in:
parent
72cd70bef2
commit
e8e163a2e9
|
@ -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"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"proxy",
|
||||
"proxy/convert",
|
||||
"proxy/controller-grpc",
|
||||
"proxy/futures-mpsc-lossy",
|
||||
"proxy/router",
|
||||
|
|
|
@ -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" }
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
[package]
|
||||
name = "convert"
|
||||
version = "0.3.0"
|
||||
publish = false
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -15,25 +15,3 @@ pub trait TryFrom<T>: Sized {
|
|||
#[doc(hidden)]
|
||||
fn try_from(t: T) -> Result<Self, Self::Err>;
|
||||
}
|
||||
|
||||
/// 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<T>: Sized {
|
||||
type Err;
|
||||
|
||||
#[doc(hidden)]
|
||||
fn try_into(self) -> Result<T, Self::Err>;
|
||||
}
|
||||
|
||||
impl<T, U> TryInto<U> for T
|
||||
where
|
||||
U: TryFrom<T>,
|
||||
{
|
||||
type Err = U::Err;
|
||||
|
||||
fn try_into(self) -> Result<U, Self::Err> {
|
||||
U::try_from(self)
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
}),
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue