diff --git a/crates/async-compression/src/generic/write/decoder.rs b/crates/async-compression/src/generic/write/decoder.rs index 757ad475..7c2353c5 100644 --- a/crates/async-compression/src/generic/write/decoder.rs +++ b/crates/async-compression/src/generic/write/decoder.rs @@ -27,7 +27,7 @@ impl Default for Decoder { } impl Decoder { - pub fn do_poll_write( + fn do_poll_write( &mut self, cx: &mut Context<'_>, input: &mut PartialBuffer<&[u8]>, @@ -73,6 +73,25 @@ impl Decoder { } } + pub fn poll_write( + &mut self, + cx: &mut Context<'_>, + buf: &[u8], + writer: Pin<&mut dyn AsyncBufWrite>, + decoder: &mut impl Decode, + ) -> Poll> { + if buf.is_empty() { + return Poll::Ready(Ok(0)); + } + + let mut input = PartialBuffer::new(buf); + + match self.do_poll_write(cx, &mut input, writer, decoder)? { + Poll::Pending if input.written().is_empty() => Poll::Pending, + _ => Poll::Ready(Ok(input.written().len())), + } + } + pub fn do_poll_flush( &mut self, cx: &mut Context<'_>, @@ -169,17 +188,6 @@ macro_rules! impl_decoder { } impl Decoder { - fn do_poll_write( - self: Pin<&mut Self>, - cx: &mut Context<'_>, - input: &mut PartialBuffer<&[u8]>, - ) -> Poll> { - let mut this = self.project(); - - this.inner - .do_poll_write(cx, input, this.writer, this.decoder) - } - fn do_poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { let mut this = self.project(); @@ -193,16 +201,9 @@ macro_rules! impl_decoder { cx: &mut Context<'_>, buf: &[u8], ) -> Poll> { - if buf.is_empty() { - return Poll::Ready(Ok(0)); - } - - let mut input = PartialBuffer::new(buf); + let mut this = self.project(); - match self.do_poll_write(cx, &mut input)? { - Poll::Pending if input.written().is_empty() => Poll::Pending, - _ => Poll::Ready(Ok(input.written().len())), - } + this.inner.poll_write(cx, buf, this.writer, this.decoder) } fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> {