diff options
author | Valentin Popov <valentin@popov.link> | 2024-01-08 00:21:28 +0300 |
---|---|---|
committer | Valentin Popov <valentin@popov.link> | 2024-01-08 00:21:28 +0300 |
commit | 1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch) | |
tree | 7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/flate2/src/ffi/mod.rs | |
parent | 5ecd8cf2cba827454317368b68571df0d13d7842 (diff) | |
download | fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip |
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/flate2/src/ffi/mod.rs')
-rw-r--r-- | vendor/flate2/src/ffi/mod.rs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/vendor/flate2/src/ffi/mod.rs b/vendor/flate2/src/ffi/mod.rs new file mode 100644 index 0000000..20b3cae --- /dev/null +++ b/vendor/flate2/src/ffi/mod.rs @@ -0,0 +1,52 @@ +//! This module contains backend-specific code. + +use crate::mem::{CompressError, DecompressError, FlushCompress, FlushDecompress, Status}; +use crate::Compression; + +/// Traits specifying the interface of the backends. +/// +/// Sync + Send are added as a condition to ensure they are available +/// for the frontend. +pub trait Backend: Sync + Send { + fn total_in(&self) -> u64; + fn total_out(&self) -> u64; +} + +pub trait InflateBackend: Backend { + fn make(zlib_header: bool, window_bits: u8) -> Self; + fn decompress( + &mut self, + input: &[u8], + output: &mut [u8], + flush: FlushDecompress, + ) -> Result<Status, DecompressError>; + fn reset(&mut self, zlib_header: bool); +} + +pub trait DeflateBackend: Backend { + fn make(level: Compression, zlib_header: bool, window_bits: u8) -> Self; + fn compress( + &mut self, + input: &[u8], + output: &mut [u8], + flush: FlushCompress, + ) -> Result<Status, CompressError>; + fn reset(&mut self); +} + +// Default to Rust implementation unless explicitly opted in to a different backend. +#[cfg(feature = "any_zlib")] +mod c; +#[cfg(feature = "any_zlib")] +pub use self::c::*; + +#[cfg(all(not(feature = "any_zlib"), feature = "miniz_oxide"))] +mod rust; +#[cfg(all(not(feature = "any_zlib"), feature = "miniz_oxide"))] +pub use self::rust::*; + +impl std::fmt::Debug for ErrorMessage { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + self.get().fmt(f) + } +} |