diff --git a/src/codec/flate/encoder.rs b/src/codec/flate/encoder.rs index 875c716a..5e8a066d 100644 --- a/src/codec/flate/encoder.rs +++ b/src/codec/flate/encoder.rs @@ -17,6 +17,10 @@ impl FlateEncoder { } } + pub(crate) fn get_ref(&self) -> &Compress { + &self.compress + } + fn encode( &mut self, input: &mut PartialBuffer>, diff --git a/src/codec/zlib/encoder.rs b/src/codec/zlib/encoder.rs index e061c135..934516c9 100644 --- a/src/codec/zlib/encoder.rs +++ b/src/codec/zlib/encoder.rs @@ -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 { diff --git a/src/futures/bufread/generic/encoder.rs b/src/futures/bufread/generic/encoder.rs index 1b6e3a1d..b14c5490 100644 --- a/src/futures/bufread/generic/encoder.rs +++ b/src/futures/bufread/generic/encoder.rs @@ -47,6 +47,10 @@ impl Encoder { self.project().reader } + pub(crate) fn get_encoder_ref(&self) -> &E { + &self.encoder + } + pub fn into_inner(self) -> R { self.reader } diff --git a/src/futures/write/generic/encoder.rs b/src/futures/write/generic/encoder.rs index 3ccfebe7..2b9d95e0 100644 --- a/src/futures/write/generic/encoder.rs +++ b/src/futures/write/generic/encoder.rs @@ -51,6 +51,10 @@ impl Encoder { 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() } diff --git a/src/macros.rs b/src/macros.rs index 8965b651..70844ad1 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -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 } ); diff --git a/src/tokio/bufread/generic/encoder.rs b/src/tokio/bufread/generic/encoder.rs index a80fa122..729e34b7 100644 --- a/src/tokio/bufread/generic/encoder.rs +++ b/src/tokio/bufread/generic/encoder.rs @@ -47,6 +47,10 @@ impl Encoder { self.project().reader } + pub(crate) fn get_encoder_ref(&self) -> &E { + &self.encoder + } + pub fn into_inner(self) -> R { self.reader } diff --git a/src/tokio/write/generic/encoder.rs b/src/tokio/write/generic/encoder.rs index ca829f7a..a722b872 100644 --- a/src/tokio/write/generic/encoder.rs +++ b/src/tokio/write/generic/encoder.rs @@ -51,6 +51,10 @@ impl Encoder { 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() }