Skip to content

Commit

Permalink
Expose total_in/total_out from underlying flate2 encoder types.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobz committed May 24, 2024
1 parent 94efb21 commit 1fcbb9c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/codec/flate/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ impl FlateEncoder {
}
}

pub(crate) fn get_ref(&self) -> &Compress {
&self.compress
}

fn encode(
&mut self,
input: &mut PartialBuffer<impl AsRef<[u8]>>,
Expand Down
4 changes: 4 additions & 0 deletions src/codec/zlib/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ impl ZlibEncoder {
inner: crate::codec::FlateEncoder::new(level, true),
}
}

pub(crate) fn get_ref(&self) -> &crate::codec::FlateEncoder {
&self.inner
}
}

impl Encode for ZlibEncoder {
Expand Down
4 changes: 4 additions & 0 deletions src/futures/bufread/generic/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ impl<R: AsyncBufRead, E: Encode> Encoder<R, E> {
self.project().reader
}

pub(crate) fn get_encoder_ref(&self) -> &E {
&self.encoder
}

pub fn into_inner(self) -> R {
self.reader
}
Expand Down
4 changes: 4 additions & 0 deletions src/futures/write/generic/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ impl<W: AsyncWrite, E: Encode> Encoder<W, E> {
self.project().writer.get_pin_mut()
}

pub(crate) fn get_encoder_ref(&self) -> &E {
&self.encoder
}

pub fn into_inner(self) -> W {
self.writer.into_inner()
}
Expand Down
10 changes: 10 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ macro_rules! algos {
),
}
}

/// Returns the total number of input bytes which have been processed by this compression object.
pub fn total_in(&self) -> u64 {
self.inner.get_encoder_ref().get_ref().get_ref().total_in()
}

/// Returns the total number of output bytes which have been produced by this compression object.
pub fn total_out(&self) -> u64 {
self.inner.get_encoder_ref().get_ref().get_ref().total_out()
}
}
{ @dec }
);
Expand Down
4 changes: 4 additions & 0 deletions src/tokio/bufread/generic/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ impl<R: AsyncBufRead, E: Encode> Encoder<R, E> {
self.project().reader
}

pub(crate) fn get_encoder_ref(&self) -> &E {
&self.encoder
}

pub fn into_inner(self) -> R {
self.reader
}
Expand Down
4 changes: 4 additions & 0 deletions src/tokio/write/generic/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ impl<W: AsyncWrite, E: Encode> Encoder<W, E> {
self.project().writer.get_pin_mut()
}

pub(crate) fn get_encoder_ref(&self) -> &E {
&self.encoder
}

pub fn into_inner(self) -> W {
self.writer.into_inner()
}
Expand Down

0 comments on commit 1fcbb9c

Please sign in to comment.