Skip to content

Commit

Permalink
chore: More clean up (#172)
Browse files Browse the repository at this point in the history
* Clean up client and codec

* Clean up codegen, server and upgrade hyper
  • Loading branch information
LucioFranco authored Dec 11, 2019
1 parent 48a69bb commit cce550b
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 170 deletions.
2 changes: 1 addition & 1 deletion tonic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ prost-derive = { version = "0.5", optional = true }
async-trait = { version = "0.1.13", optional = true }

# transport
hyper = { git = "https://github.com/hyperium/hyper", features = ["stream"], optional = true }
hyper = { version = "0.13", features = ["stream"], optional = true }
tokio = { version = "0.2", features = ["tcp"], optional = true }
tower = { git = "https://github.com/tower-rs/tower", optional = true}
tower-make = { version = "0.3", features = ["connect"] }
Expand Down
8 changes: 2 additions & 6 deletions tonic/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ impl BoxBody {
pub fn map_from<B>(inner: B) -> Self
where
B: Body + Send + Sync + 'static,
// B::Data: Into<Bytes>,
B::Error: Into<crate::Error>,
{
BoxBody {
Expand Down Expand Up @@ -143,7 +142,6 @@ impl HttpBody for BoxBody {
impl<B> HttpBody for MapBody<B>
where
B: Body,
// B::Data: Into<Bytes>,
B::Error: Into<crate::Error>,
{
type Data = Bytes;
Expand Down Expand Up @@ -206,17 +204,15 @@ impl HttpBody for EmptyBody {

fn poll_data(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
_cx: &mut Context<'_>,
) -> Poll<Option<Result<Self::Data, Self::Error>>> {
drop(cx);
Poll::Ready(None)
}

fn poll_trailers(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
_cx: &mut Context<'_>,
) -> Poll<Result<Option<http::HeaderMap>, Self::Error>> {
drop(cx);
Poll::Ready(Ok(None))
}
}
8 changes: 2 additions & 6 deletions tonic/src/client/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ impl<T> Grpc<T> {
T: GrpcService<BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
<T::ResponseBody as HttpBody>::Error: Into<crate::Error>,
// <T::ResponseBody as HttpBody>::Data: Into<Bytes>,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
Expand All @@ -79,7 +78,6 @@ impl<T> Grpc<T> {
T: GrpcService<BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
<T::ResponseBody as HttpBody>::Error: Into<crate::Error>,
// <T::ResponseBody as HttpBody>::Data: Into<Bytes>,
S: Stream<Item = M1> + Send + Sync + 'static,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
Expand Down Expand Up @@ -112,7 +110,6 @@ impl<T> Grpc<T> {
T: GrpcService<BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
<T::ResponseBody as HttpBody>::Error: Into<crate::Error>,
// <T::ResponseBody as HttpBody>::Data: Into<Bytes>,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
Expand All @@ -131,7 +128,6 @@ impl<T> Grpc<T> {
where
T: GrpcService<BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
// <T::ResponseBody as HttpBody>::Data: Into<Bytes>,
<T::ResponseBody as HttpBody>::Error: Into<crate::Error>,
S: Stream<Item = M1> + Send + Sync + 'static,
C: Codec<Encode = M1, Decode = M2>,
Expand Down Expand Up @@ -200,8 +196,8 @@ impl<T: Clone> Clone for Grpc<T> {
}
}

impl<T> fmt::Debug for Grpc<T> {
impl<T: fmt::Debug> fmt::Debug for Grpc<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Grpc").finish()
f.debug_struct("Grpc").field("inner", &self.inner).finish()
}
}
4 changes: 0 additions & 4 deletions tonic/src/codec/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ impl<T> Streaming<T> {
pub(crate) fn new_response<B, D>(decoder: D, body: B, status_code: StatusCode) -> Self
where
B: Body + Send + Sync + 'static,
// B::Data: Into<Bytes>,
B::Error: Into<crate::Error>,
D: Decoder<Item = T, Error = Status> + Send + Sync + 'static,
{
Expand All @@ -56,7 +55,6 @@ impl<T> Streaming<T> {
pub(crate) fn new_empty<B, D>(decoder: D, body: B) -> Self
where
B: Body + Send + Sync + 'static,
// B::Data: Into<Bytes>,
B::Error: Into<crate::Error>,
D: Decoder<Item = T, Error = Status> + Send + Sync + 'static,
{
Expand All @@ -66,7 +64,6 @@ impl<T> Streaming<T> {
pub(crate) fn new_request<B, D>(decoder: D, body: B) -> Self
where
B: Body + Send + Sync + 'static,
// B::Data: Into<Bytes>,
B::Error: Into<crate::Error>,
D: Decoder<Item = T, Error = Status> + Send + Sync + 'static,
{
Expand All @@ -76,7 +73,6 @@ impl<T> Streaming<T> {
fn new<B, D>(decoder: D, body: B, direction: Direction) -> Self
where
B: Body + Send + Sync + 'static,
// B::Data: Into<Bytes>,
B::Error: Into<crate::Error>,
D: Decoder<Item = T, Error = Status> + Send + Sync + 'static,
{
Expand Down
Loading

0 comments on commit cce550b

Please sign in to comment.