1 //! This module contains backend-specific code.
3 use crate::mem
::{CompressError, DecompressError, FlushCompress, FlushDecompress, Status}
;
4 use crate::Compression
;
6 /// Traits specifying the interface of the backends.
8 /// Sync + Send are added as a condition to ensure they are available
10 pub trait Backend
: Sync
+ Send
{
11 fn total_in(&self) -> u64;
12 fn total_out(&self) -> u64;
15 pub trait InflateBackend
: Backend
{
16 fn make(zlib_header
: bool
, window_bits
: u8) -> Self;
21 flush
: FlushDecompress
,
22 ) -> Result
<Status
, DecompressError
>;
23 fn reset(&mut self, zlib_header
: bool
);
26 pub trait DeflateBackend
: Backend
{
27 fn make(level
: Compression
, zlib_header
: bool
, window_bits
: u8) -> Self;
33 ) -> Result
<Status
, CompressError
>;
37 // Default to Rust implementation unless explicitly opted in to a different backend.
38 #[cfg(feature = "any_zlib")]
40 #[cfg(feature = "any_zlib")]
43 #[cfg(not(feature = "any_zlib"))]
45 #[cfg(not(feature = "any_zlib"))]
46 pub use self::rust
::*;
48 impl std
::fmt
::Debug
for ErrorMessage
{
49 fn fmt(&self, f
: &mut std
::fmt
::Formatter
) -> std
::fmt
::Result
{