| 55 | type Error = CoderError; |
| 56 | |
| 57 | fn poll_frame(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>> { |
| 58 | let mut this = self.project(); |
| 59 | |
| 60 | while let Some(res) = ready!(this.body.as_mut().poll_frame(cx)) { |
| 61 | match res? { |
| 62 | Frame::Data(item) => { |
| 63 | if let Some(item) = this.coder.code(item)? { |
| 64 | return Poll::Ready(Some(Ok(Frame::Data(item)))); |
| 65 | } |
| 66 | } |
| 67 | Frame::Trailers(trailers) => { |
| 68 | this.trailers.replace(trailers); |
| 69 | break; |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | match this.coder.code_eof()? { |
| 75 | Some(res) => Poll::Ready(Some(Ok(Frame::Data(res)))), |
| 76 | None => Poll::Ready(this.trailers.take().map(|trailsers| Ok(Frame::Trailers(trailsers)))), |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | fn is_end_stream(&self) -> bool { |
| 81 | // forward is_end_stream to coder as it determines the data length after (de)compress. |