Skip to content

Commit

Permalink
chore(codec): Remove redundant type converting (#1504)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Nov 15, 2023
1 parent 7cb1cd2 commit 53267a3
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions tonic/src/codec/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,13 @@ impl StreamingInner {
fn poll_data(&mut self, cx: &mut Context<'_>) -> Poll<Result<Option<()>, Status>> {
let chunk = match ready!(Pin::new(&mut self.body).poll_data(cx)) {
Some(Ok(d)) => Some(d),
Some(Err(e)) => {
if self.direction == Direction::Request && e.code() == Code::Cancelled {
Some(Err(status)) => {
if self.direction == Direction::Request && status.code() == Code::Cancelled {
return Poll::Ready(Ok(None));
}

let _ = std::mem::replace(&mut self.state, State::Error);
let err: crate::Error = e.into();
debug!("decoder inner stream error: {:?}", err);
let status = Status::from_error(err);
debug!("decoder inner stream error: {:?}", status);
return Poll::Ready(Err(status));
}
None => None,
Expand Down Expand Up @@ -278,10 +276,8 @@ impl StreamingInner {
self.trailers = trailer.map(MetadataMap::from_headers);
}
}
Err(e) => {
let err: crate::Error = e.into();
debug!("decoder inner trailers error: {:?}", err);
let status = Status::from_error(err);
Err(status) => {
debug!("decoder inner trailers error: {:?}", status);
return Poll::Ready(Err(status));
}
}
Expand Down

0 comments on commit 53267a3

Please sign in to comment.