### Initialize Crc with Default Value Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Crc.html Creates a new Crc instance with an initial CRC32 value of 0. This is the standard way to start a CRC calculation. ```rust pub const fn new() -> Crc ``` -------------------------------- ### Create a New Decompressor Instance Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Decompressor.html Instantiates a new Decompressor. This is the entry point for using the decompressor. ```rust pub fn new() -> Decompressor ``` -------------------------------- ### Get Current Crc Sum Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Crc.html Returns the current CRC32 checksum value. This can be called at any point after initialization or updates to get the intermediate or final checksum. ```rust pub const fn sum(&self) -> u32 ``` -------------------------------- ### Adler32::new Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Adler32.html Creates a new Adler32 instance with the default initial value (1). ```APIDOC ## Adler32::new ### Description Returns a new `Adler32` instance with the initial adler32 value 1, which is the default for adler32. ### Method `const fn new() -> Adler32` ``` -------------------------------- ### Adler32::with_initial Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Adler32.html Creates a new Adler32 instance with a specified initial value. ```APIDOC ## Adler32::with_initial ### Description Returns a new `Adler32` instance with a chosen initial value. ### Method `const fn with_initial(val: u32) -> Adler32` ### Parameters * **val** (u32) - The initial value for the Adler32 checksum. ``` -------------------------------- ### Compression Operations Source: https://docs.rs/libdeflater/1.25.2/libdeflater Construct a Compressor and compress data into DEFLATE, zlib, or gzip formats. Output buffers must be large enough to hold the compressed data, and bounds can be calculated using `*_bound` methods. ```APIDOC ## Compressor ### Description A `libdeflate` compressor that can compress arbitrary data into DEFLATE, zlib, or gzip formats. ### Methods - `Compressor::new()`: Constructs a new `Compressor`. - `deflate_compress(input_buffer, output_buffer)`: Compresses data into DEFLATE format. - `zlib_compress(input_buffer, output_buffer)`: Compresses data into zlib format. - `gzip_compress(input_buffer, output_buffer)`: Compresses data into gzip format. - `deflate_compress_bound(input_size)`: Returns the maximum bound for DEFLATE compressed data. - `zlib_compress_bound(input_size)`: Returns the maximum bound for zlib compressed data. - `gzip_compress_bound(input_size)`: Returns the maximum bound for gzip compressed data. ### Notes - Developers need to supply output buffers large enough to fit the compressed data. - The maximum size of compressed data can be determined using the associated `*_bound` methods. ``` -------------------------------- ### CompressionLvl::new Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvl.html Attempts to create a valid `CompressionLvl` from a numeric value. Returns `Ok(CompressionLvl)` if the level is valid (1-12 for libdeflate), otherwise returns `Err(CompressionLvlError)`. ```APIDOC ## pub const fn new(level: i32) -> Result Try to create a valid `CompressionLvl` from a numeric value. If `level` is a valid custom compression level for libdeflate, returns a `Result::Ok(CompressionLvl)`. Otherwise, returns `Result::Error(error)`. Valid compression levels for libdeflate, at time of writing, are 1-12. ``` -------------------------------- ### Create Compression Level from Integer Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Attempts to create a `CompressionLvl` from an integer. Valid levels are between 0 and 12 inclusive. Returns an error if the value is out of range. ```rust pub const fn new(level: i32) -> CompressionLevelResult { if MIN_COMPRESSION_LVL <= level && level <= MAX_COMPRESSION_LVL { Ok(CompressionLvl(level)) } else { Err(CompressionLvlError::InvalidValue) } } ``` -------------------------------- ### Compressor::default Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Creates a Compressor with the default compression level recommended by libdeflate. ```APIDOC ## Compressor::default ### Description Returns the default compression level recommended by libdeflate. ### Signature ```rust impl Default for Compressor { fn default() -> Self; } ``` ``` -------------------------------- ### take Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Creates an iterator that yields the first `n` elements, or fewer if the underlying iterator ends sooner. ```APIDOC ## fn take(self, n: usize) -> Take ### Description Creates an iterator that yields the first `n` elements, or fewer if the underlying iterator ends sooner. ### Parameters - **n** (usize) - The maximum number of elements to yield. ``` -------------------------------- ### Compressor::new Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Compressor.html Returns a newly constructed Compressor that compresses data with the supplied CompressionLvl. ```APIDOC ## Compressor::new ### Description Returns a newly constructed `Compressor` that compresses data with the supplied `CompressionLvl`. ### Signature ```rust pub fn new(lvl: CompressionLvl) -> Compressor ``` ### Parameters * `lvl` (CompressionLvl) - The compression level to use. ``` -------------------------------- ### Compression Source: https://docs.rs/libdeflater/1.25.2/index.html Construct a Compressor to compress data into DEFLATE, zlib, or gzip formats. Requires pre-allocated output buffers, with maximum size determinable via `*_bound` methods. ```APIDOC ## Compression `Compressor::new` can be used to construct a `Compressor`, which can compress data into the following formats: * DEFLATE (`deflate_compress`) * zlib (`zlib_compress`) * gzip (`gzip_compress`) Because buffers must be allocated up-front, developers need to supply these functions with output buffers that are big enough to fit the compressed data. The maximum size of the compressed data can be found with the associated `*_bound` methods: * `deflate_compress_bound` * `zlib_compress_bound` * `gzip_compress_bound` ``` -------------------------------- ### clone_to_uninit Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvl.html Performs copy-assignment from `self` to `dest`. This is a nightly-only experimental API. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description Performs copy-assignment from `self` to `dest`. ### Safety This function is unsafe because it performs a raw pointer write. The caller must ensure that `dest` is a valid, mutable pointer to a buffer of sufficient size to hold the data. ### Note This is a nightly-only experimental API. ``` -------------------------------- ### Initialize Decompressor in Rust Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Creates a new Decompressor instance. Panics if memory allocation fails. ```rust pub fn new() -> Decompressor { unsafe { let ptr = alloc_decompressor(); if let Some(ptr) = NonNull::new(ptr) { Decompressor{ p: ptr } } else { panic!("libdeflate_alloc_decompressor returned NULL: out of memory"); } } } ``` -------------------------------- ### Zlib Compression with libdeflater Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Compresses raw data into zlib format. Ensure the output buffer has sufficient space. ```rust pub fn zlib_compress(&mut self, in_raw_data: &[u8], out_zlib_data: &mut [u8]) -> CompressionResult { unsafe { let in_ptr = in_raw_data.as_ptr() as *const std::ffi::c_void; let out_ptr = out_zlib_data.as_mut_ptr() as *mut std::ffi::c_void; let sz = libdeflate_zlib_compress(self.p.as_ptr(), in_ptr, in_raw_data.len(), out_ptr, out_zlib_data.len()); if sz != 0 { Ok(sz) } else { Err(CompressionError::InsufficientSpace) } } } ``` -------------------------------- ### partition Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Consumes an iterator, creating two collections from it. ```APIDOC ## fn partition(self, f: F) -> (B, B) ### Description Consumes an iterator, creating two collections from it. ### Parameters - **f** (F) - A closure that returns `true` if the element should go into the first collection, `false` otherwise. ### Type Parameters - **B**: Must implement `Default` and `Extend`. ``` -------------------------------- ### Decompressor::new Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Decompressor.html Constructs a new Decompressor instance. ```APIDOC ## Decompressor::new ### Description Returns a newly constructed instance of a `Decompressor`. ### Signature ```rust pub fn new() -> Decompressor ``` ``` -------------------------------- ### CompressionLvl::best Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvl.html Returns the best compression level, prioritizing compression ratio over performance. ```APIDOC ## pub const fn best() -> CompressionLvl Returns the best compression level, in terms of compression ratio. This compression level offers the best compression ratio but lowest performance. ``` -------------------------------- ### by_ref Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Creates a “by reference” adapter for this instance of `Iterator`. ```APIDOC ## fn by_ref(&mut self) -> &mut Self ### Description Creates a “by reference” adapter for this instance of `Iterator`. ``` -------------------------------- ### Compressor::zlib_compress Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Compressor.html Compresses raw data as zlib data into the provided output buffer. ```APIDOC ## Compressor::zlib_compress ### Description Compresses `in_raw_data` as `zlib` data, writing the data into `out_zlib_data`. Returns the number of bytes written into `out_zlib_data`. ### Signature ```rust pub fn zlib_compress(&mut self, in_raw_data: &[u8], out_zlib_data: &mut [u8]) -> Result ``` ### Parameters * `in_raw_data` (&[u8]) - The raw input data to compress. * `out_zlib_data` (&mut [u8]) - The buffer to write the compressed zlib data into. ``` -------------------------------- ### Compressor::gzip_compress Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Compressor.html Compresses raw data as gzip data into the provided output buffer. ```APIDOC ## Compressor::gzip_compress ### Description Compresses `in_raw_data` as `gzip` data, writing the data into `out_gzip_data`. Returns the number of bytes written into `out_gzip_data`. ### Signature ```rust pub fn gzip_compress(&mut self, in_raw_data: &[u8], out_gzip_data: &mut [u8]) -> Result ``` ### Parameters * `in_raw_data` (&[u8]) - The raw input data to compress. * `out_gzip_data` (&mut [u8]) - The buffer to write the compressed gzip data into. ``` -------------------------------- ### Gzip Compression with libdeflater Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Compresses raw data into gzip format. The output buffer must be large enough to hold the compressed data. ```rust pub fn gzip_compress(&mut self, in_raw_data: &[u8], out_gzip_data: &mut [u8]) -> CompressionResult { unsafe { let in_ptr = in_raw_data.as_ptr() as *const std::ffi::c_void; let out_ptr = out_gzip_data.as_mut_ptr() as *mut std::ffi::c_void; let sz = libdeflate_gzip_compress(self.p.as_ptr(), in_ptr, in_raw_data.len(), out_ptr, out_gzip_data.len()); if sz != 0 { Ok(sz) } else { Err(CompressionError::InsufficientSpace) } } } ``` -------------------------------- ### product Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Iterates over the entire iterator, multiplying all the elements. ```APIDOC ## fn product

(self) -> P where Self: Sized, P: Product, ### Description Iterates over the entire iterator, multiplying all the elements. ``` -------------------------------- ### Comparison Methods Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html These methods allow for comparing the elements of the CompressionLvlIter with another iterator. ```APIDOC ## fn ne(self, other: I) -> bool ### Description Determines if the elements of this `Iterator` are not equal to those of another. ### Method `ne` ### Parameters - `other`: An iterator that can be compared with `Self::Item`. ### Returns `bool` - `true` if the iterators are not equal, `false` otherwise. ``` ```APIDOC ## fn lt(self, other: I) -> bool ### Description Determines if the elements of this `Iterator` are lexicographically less than those of another. ### Method `lt` ### Parameters - `other`: An iterator that can be compared with `Self::Item`. ### Returns `bool` - `true` if this iterator's elements are lexicographically less than the other's, `false` otherwise. ``` ```APIDOC ## fn le(self, other: I) -> bool ### Description Determines if the elements of this `Iterator` are lexicographically less than or equal to those of another. ### Method `le` ### Parameters - `other`: An iterator that can be compared with `Self::Item`. ### Returns `bool` - `true` if this iterator's elements are lexicographically less than or equal to the other's, `false` otherwise. ``` ```APIDOC ## fn gt(self, other: I) -> bool ### Description Determines if the elements of this `Iterator` are lexicographically greater than those of another. ### Method `gt` ### Parameters - `other`: An iterator that can be compared with `Self::Item`. ### Returns `bool` - `true` if this iterator's elements are lexicographically greater than the other's, `false` otherwise. ``` ```APIDOC ## fn ge(self, other: I) -> bool ### Description Determines if the elements of this `Iterator` are lexicographically greater than or equal to those of another. ### Method `ge` ### Parameters - `other`: An iterator that can be compared with `Self::Item`. ### Returns `bool` - `true` if this iterator's elements are lexicographically greater than or equal to the other's, `false` otherwise. ``` -------------------------------- ### Crc::with_initial Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Crc.html Creates a new Crc instance with a specified initial CRC32 value. ```APIDOC ## Crc::with_initial ### Description Returns a new `Crc` instance with chosen initial value. ### Method `const fn with_initial(val: u32) -> Crc` ``` -------------------------------- ### Gzip Compression Bound Calculation Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Calculates the maximum required buffer size for gzip compression. This is a worst-case estimate. ```rust pub fn gzip_compress_bound(&mut self, n_bytes: usize) -> usize { unsafe { libdeflate_gzip_compress_bound(self.p.as_ptr(), n_bytes) } } ``` -------------------------------- ### Initialize Adler32 with Custom Value Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Adler32.html Creates a new Adler32 instance with a specified initial checksum value. ```rust pub const fn with_initial(val: u32) -> Adler32 ``` -------------------------------- ### Crc::new Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Crc.html Creates a new Crc instance with an initial CRC32 value of 0. ```APIDOC ## Crc::new ### Description Returns a new `Crc` instance (with initial value 0). ### Method `const fn new() -> Crc` ``` -------------------------------- ### impl Iterator for CompressionLvlIter Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Provides standard iterator methods for CompressionLvlIter. ```APIDOC ### type Item = CompressionLvl The type of the elements being iterated over. ### fn next(&mut self) -> Option Advances the iterator and returns the next value. ### fn next_chunk( &mut self, ) -> Result<[Self::Item; N], IntoIter> Advances the iterator and returns an array containing the next `N` values. This is a nightly-only experimental API. ### fn size_hint(&self) -> (usize, Option) Returns the bounds on the remaining length of the iterator. ### fn count(self) -> usize Consumes the iterator, counting the number of iterations and returning it. ### fn last(self) -> Option Consumes the iterator, returning the last element. ### fn advance_by(&mut self, n: usize) -> Result<(), NonZero> Advances the iterator by `n` elements. This is a nightly-only experimental API. ### fn nth(&mut self, n: usize) -> Option Returns the `n`th element of the iterator. ### fn step_by(self, step: usize) -> StepBy Creates an iterator starting at the same point, but stepping by the given amount at each iteration. ### fn chain(self, other: U) -> Chain::IntoIter> Takes two iterators and creates a new iterator over both in sequence. ### fn zip(self, other: U) -> Zip::IntoIter> ‘Zips up’ two iterators into a single iterator of pairs. ### fn intersperse(self, separator: Self::Item) -> Intersperse Creates a new iterator which places a copy of `separator` between adjacent items of the original iterator. This is a nightly-only experimental API. ### fn intersperse_with(self, separator: G) -> IntersperseWith Creates a new iterator which places an item generated by `separator` between adjacent items of the original iterator. This is a nightly-only experimental API. ### fn map(self, f: F) -> Map Takes a closure and creates an iterator which calls that closure on each element. ### fn for_each(self, f: F) Calls a closure on each element of an iterator. ### fn filter

(self, predicate: P) -> Filter Creates an iterator which uses a closure to determine if an element should be yielded. ### fn filter_map(self, f: F) -> FilterMap Creates an iterator that both filters and maps. ### fn enumerate(self) -> Enumerate Creates an iterator which gives the current iteration count as well as the next value. ### fn peekable(self) -> Peekable Creates an iterator which can use the `peek` and `peek_mut` methods to look at the next element of the iterator without consuming it. ### fn skip_while

(self, predicate: P) -> SkipWhile Creates an iterator that `skip`s elements based on a predicate. ### fn take_while

(self, predicate: P) -> TakeWhile Creates an iterator that yields elements based on a predicate. ### fn map_while(self, predicate: P) -> MapWhile Creates an iterator that both yields elements based on a predicate and maps. ### fn skip(self, n: usize) -> Skip Creates an iterator that skips the first `n` elements. ``` -------------------------------- ### CompressionLvl::iter Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvl.html Returns an iterator that yields all compression levels supported by `libdeflate` in ascending order. ```APIDOC ## pub const fn iter() -> CompressionLvlIter Returns an iterator that emits all compression levels supported by `libdeflate` in ascending order. ``` -------------------------------- ### inspect Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Does something with each element of an iterator, passing the value on. ```APIDOC ## fn inspect(self, f: F) -> Inspect ### Description Does something with each element of an iterator, passing the value on. ### Parameters - **f** (F) - A closure that takes a reference to the item. ``` -------------------------------- ### Decompression Source: https://docs.rs/libdeflater/1.25.2/index.html Construct a Decompressor to decompress DEFLATE, zlib, or gzip data. Requires pre-allocated input and output buffers. ```APIDOC ## Decompression `Decompressor::new` can be used to construct a `Decompressor`, which can decompress: * DEFLATE data (`deflate_decompress`) * zlib data (`zlib_decompress`) * gzip data (`gzip_decompress`) **Note**: `libdeflate` requires that the input _and_ output buffers are pre-allocated before decompressing. Because of this, you will at least need to know the upper bound on how large the compressed data will decompress to; otherwise, a `decompress_*` function call will return `DecompressionError::InsufficientSpace` ``` -------------------------------- ### Best Compression Level Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Returns the best compression level (level 12), which prioritizes compression ratio over speed. ```rust pub const fn best() -> CompressionLvl { CompressionLvl(MAX_COMPRESSION_LVL) } ``` -------------------------------- ### CompressionLvl::fastest Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvl.html Returns the fastest compression level. This level prioritizes performance over compression ratio. ```APIDOC ## pub const fn fastest() -> CompressionLvl Returns the fastest compression level. This compression level offers the highest performance but lowest compression ratio. ``` -------------------------------- ### CompressionLvl::default Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvl.html Returns the default compression level recommended by libdeflate. ```APIDOC ## fn default() -> CompressionLvl Returns the default compression level reccomended by libdeflate. ``` -------------------------------- ### map_windows Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Calls the given function `f` for each contiguous window of size `N` over `self` and returns an iterator over the outputs of `f`. Like `slice::windows()`, the windows during mapping overlap as well. ```APIDOC ## fn map_windows(self, f: F) -> MapWindows ### Description Calls the given function `f` for each contiguous window of size `N` over `self` and returns an iterator over the outputs of `f`. Like `slice::windows()`, the windows during mapping overlap as well. ### Parameters - **f** (F) - A closure that takes a slice representing the window and returns a value. - **N** (const usize) - The size of the sliding window. ``` -------------------------------- ### Zlib Compression Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Compresses raw data into zlib format. It takes raw input data and an output buffer, returning the number of bytes written to the output buffer or an error if the output buffer is insufficient. ```APIDOC ## zlib_compress ### Description Compresses `in_raw_data` as zlib data, writing the data into `out_zlib_data`. Returns the number of bytes written into `out_zlib_data`. ### Method `pub fn zlib_compress(&mut self, in_raw_data: &[u8], out_zlib_data: &mut [u8]) -> CompressionResult` ### Parameters - `in_raw_data` (&[u8]): The raw input data to compress. - `out_zlib_data` (&mut [u8]): The buffer to write the compressed zlib data into. ### Return Value - `CompressionResult`: Ok(number of bytes written) on success, or `CompressionError::InsufficientSpace` if the output buffer is too small. ``` -------------------------------- ### Initialize Adler32 with Default Value Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Adler32.html Creates a new Adler32 instance with the default initial checksum value of 1. ```rust pub const fn new() -> Adler32 ``` -------------------------------- ### Decompression Operations Source: https://docs.rs/libdeflater/1.25.2/libdeflater Construct a Decompressor and perform decompression on DEFLATE, zlib, or gzip data. Note that input and output buffers must be pre-allocated. ```APIDOC ## Decompressor ### Description A `libdeflate` decompressor that can inflate DEFLATE, zlib, or gzip data. ### Methods - `Decompressor::new()`: Constructs a new `Decompressor`. - `deflate_decompress(input_buffer, output_buffer)`: Decompresses raw DEFLATE data. - `zlib_decompress(input_buffer, output_buffer)`: Decompresses zlib data. - `gzip_decompress(input_buffer, output_buffer)`: Decompresses gzip data. ### Notes - Input and output buffers must be pre-allocated. - If the output buffer is insufficient, `DecompressionError::InsufficientSpace` will be returned. ``` -------------------------------- ### Gzip Compression Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Compresses raw data into gzip format. It takes raw input data and an output buffer, returning the number of bytes written to the output buffer or an error if the output buffer is insufficient. ```APIDOC ## gzip_compress ### Description Compresses `in_raw_data` as gzip data, writing the data into `out_gzip_data`. Returns the number of bytes written into `out_gzip_data`. ### Method `pub fn gzip_compress(&mut self, in_raw_data: &[u8], out_gzip_data: &mut [u8]) -> CompressionResult` ### Parameters - `in_raw_data` (&[u8]): The raw input data to compress. - `out_gzip_data` (&mut [u8]): The buffer to write the compressed gzip data into. ### Return Value - `CompressionResult`: Ok(number of bytes written) on success, or `CompressionError::InsufficientSpace` if the output buffer is too small. ``` -------------------------------- ### Compressor::deflate_compress Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Compressor.html Compresses raw data as deflate data into the provided output buffer. ```APIDOC ## Compressor::deflate_compress ### Description Compresses `in_raw_data` as `deflate` data, writing the data into `out_deflate_data`. Returns the number of bytes written into `out_deflate_data`. ### Signature ```rust pub fn deflate_compress(&mut self, in_raw_data: &[u8], out_deflate_data: &mut [u8]) -> Result ``` ### Parameters * `in_raw_data` (&[u8]) - The raw input data to compress. * `out_deflate_data` (&mut [u8]) - The buffer to write the compressed deflate data into. ``` -------------------------------- ### IntoIterator Implementation Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Allows the CompressionLvlIter to be used in contexts that require an iterator. ```APIDOC ## impl IntoIterator for I ### Description Provides the ability to convert the iterator into itself, enabling its use in `for` loops and other iterator-consuming operations. ### Associated Types - `Item`: The type of the elements being iterated over. - `IntoIter`: The type of the iterator itself. ### Method `into_iter` ### Returns `I` - The iterator itself. ``` -------------------------------- ### Decompressor::zlib_decompress Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Decompressor.html Decompresses zlib data. ```APIDOC ## Decompressor::zlib_decompress ### Description Decompresses `zlib_data` (a buffer containing `zlib` data) and writes the decompressed data to `out`. Returns the number of decompressed bytes written into `out`, or an error (see `DecompressionError` for error cases). ### Signature ```rust pub fn zlib_decompress(&mut self, zlib_data: &[u8], out: &mut [u8]) -> Result ``` ``` -------------------------------- ### any Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Tests if any element of the iterator matches a predicate. ```APIDOC ## fn any(&mut self, f: F) -> bool ### Description Tests if any element of the iterator matches a predicate. ### Parameters - **f** (F) - A closure that takes an item and returns a boolean. ``` -------------------------------- ### fold Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Folds every element into an accumulator by applying an operation, returning the final result. ```APIDOC ## fn fold(self, init: B, f: F) -> B ### Description Folds every element into an accumulator by applying an operation, returning the final result. ### Parameters - **init** (B) - The initial value for the accumulator. - **f** (F) - A closure that takes the accumulator and the next item, returning the updated accumulator. ``` -------------------------------- ### Initialize Crc with Custom Value Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Crc.html Creates a new Crc instance with a specified initial CRC32 value. Useful for continuing a CRC calculation or for specific protocols. ```rust pub const fn with_initial(val: u32) -> Crc ``` -------------------------------- ### cloned Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Creates an iterator which `clone`s all of its elements. ```APIDOC ## fn cloned<'a, T>(self) -> Cloned where T: Clone + 'a, Self: Sized + Iterator, ### Description Creates an iterator which `clone`s all of its elements. ``` -------------------------------- ### Fastest Compression Level Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Returns the fastest compression level (level 0), which prioritizes speed over compression ratio. ```rust pub const fn fastest() -> CompressionLvl { CompressionLvl(MIN_COMPRESSION_LVL) } ``` -------------------------------- ### Compressor::deflate_compress_bound Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Calculates the maximum buffer size needed for DEFLATE compression. ```APIDOC ## Compressor::deflate_compress_bound ### Description Returns the maximum number of bytes required to encode `n_bytes` as [`deflate`](https://tools.ietf.org/html/rfc1951) data. This is a hard upper-bound that assumes the worst possible compression ratio (i.e. assumes the data cannot be compressed), format overhead, etc. ### Signature ```rust pub fn deflate_compress_bound(&mut self, n_bytes: usize) -> usize ``` ### Parameters * `n_bytes` (`usize`): The number of bytes in the input data. ``` -------------------------------- ### CompressionLvlIter Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html An iterator over the `CompressionLvl`s supported by the `Compressor`. ```APIDOC ## Struct CompressionLvlIter An iterator over the `CompressionLvl`s supported by the `Compressor`. ```rust pub struct CompressionLvlIter(/* private fields */); ``` ``` -------------------------------- ### partial_cmp_by Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Lexicographically compares the elements of this `Iterator` with those of another with respect to the specified comparison function. This is a nightly-only experimental API. ```APIDOC ## fn partial_cmp_by(self, other: I, partial_cmp: F) -> Option where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, ::Item) -> Option, ### Description Lexicographically compares the elements of this `Iterator` with those of another with respect to the specified comparison function. ### Note This is a nightly-only experimental API. ``` -------------------------------- ### copied Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Creates an iterator which copies all of its elements. ```APIDOC ## fn copied<'a, T>(self) -> Copied where T: Copy + 'a, Self: Sized + Iterator, ### Description Creates an iterator which copies all of its elements. ``` -------------------------------- ### TryFrom for T Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvl.html Implementation of the `TryFrom` trait for fallible conversions. ```APIDOC ### impl TryFrom for T where U: Into, #### type Error = Infallible ### Description The type returned in the event of a conversion error. #### fn try_from(value: U) -> Result>::Error> ### Description Performs the conversion. ``` -------------------------------- ### TryInto for T Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvl.html Implementation of the `TryInto` trait for fallible conversions. ```APIDOC ### impl TryInto for T where U: TryFrom, #### type Error = >::Error ### Description The type returned in the event of a conversion error. #### fn try_into(self) -> Result>::Error> ### Description Performs the conversion. ``` -------------------------------- ### min_by_key Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Returns the element that gives the minimum value from the specified function. ```APIDOC ## fn min_by_key(self, f: F) -> Option where B: Ord, Self: Sized, F: FnMut(&Self::Item) -> B, ### Description Returns the element that gives the minimum value from the specified function. ``` -------------------------------- ### cmp_by Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Lexicographically compares the elements of this `Iterator` with those of another with respect to the specified comparison function. This is a nightly-only experimental API. ```APIDOC ## fn cmp_by(self, other: I, cmp: F) -> Ordering where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, ::Item) -> Ordering, ### Description Lexicographically compares the elements of this `Iterator` with those of another with respect to the specified comparison function. ### Note This is a nightly-only experimental API. ``` -------------------------------- ### scan Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html An iterator adapter which, like `fold`, holds internal state, but unlike `fold`, produces a new iterator. ```APIDOC ## fn scan(self, initial_state: St, f: F) -> Scan ### Description An iterator adapter which, like `fold`, holds internal state, but unlike `fold`, produces a new iterator. ### Parameters - **initial_state** (St) - The initial state for the adapter. - **f** (F) - A closure that takes the mutable state and the next item, returning an `Option` of the next item to yield. ``` -------------------------------- ### Decompress Deflate Data with libdeflater Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Decompresses data compressed using the deflate algorithm. Ensure the output buffer is large enough to hold the decompressed data. Handles potential errors like bad data or insufficient space. ```rust unsafe { let mut out_nbytes = 0; let in_ptr = deflate_data.as_ptr() as *const std::ffi::c_void; let out_ptr = out.as_mut_ptr() as *mut std::ffi::c_void; let ret: libdeflate_result = libdeflate_deflate_decompress(self.p.as_ptr(), in_ptr, deflate_data.len(), out_ptr, out.len(), &mut out_nbytes); match ret { libdeflate_result_LIBDEFLATE_SUCCESS => { Ok(out_nbytes) }, libdeflate_result_LIBDEFLATE_BAD_DATA => { Err(DecompressionError::BadData) }, libdeflate_result_LIBDEFLATE_INSUFFICIENT_SPACE => { Err(DecompressionError::InsufficientSpace) }, _ => { panic!("libdeflate_deflate_decompress returned an unknown error type: this is an internal bug that **must** be fixed"); } } } ``` -------------------------------- ### Checksum Functions Source: https://docs.rs/libdeflater/1.25.2/libdeflater/index.html Provides functions to calculate Adler32 and CRC32 checksums for given data. ```APIDOC ## Functions§ adler32 Returns the Adler32 checksum of the bytes in `data`. crc32 Returns the CRC32 checksum of the bytes in `data`. ``` -------------------------------- ### Decompressor::gzip_decompress Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Decompressor.html Decompresses gzip data. ```APIDOC ## Decompressor::gzip_decompress ### Description Decompresses `gz_data` (a buffer containing `gzip` data) and writes the decompressed data into `out`. Returns the number of decompressed bytes written into `out`, or an error (see `DecompressionError` for error cases). ### Signature ```rust pub fn gzip_decompress(&mut self, gz_data: &[u8], out: &mut [u8]) -> Result ``` ``` -------------------------------- ### Gzip Compression Bound Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Calculates the maximum number of bytes required to encode raw data as gzip format. This is a worst-case upper bound. ```APIDOC ## gzip_compress_bound ### Description Returns the maximum number of bytes required to encode `n_bytes` as gzip data. This is a hard upper-bound that assumes the worst possible compression ratio. ### Method `pub fn gzip_compress_bound(&mut self, n_bytes: usize) -> usize` ### Parameters - `n_bytes` (usize): The number of bytes in the raw input data. ### Return Value - `usize`: The maximum number of bytes required for gzip compression. ``` -------------------------------- ### min Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Returns the minimum element of an iterator. ```APIDOC ## fn min(self) -> Option where Self: Sized, Self::Item: Ord, ### Description Returns the minimum element of an iterator. ``` -------------------------------- ### unzip Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Converts an iterator of pairs into a pair of containers. ```APIDOC ## fn unzip(self) -> (FromA, FromB) where FromA: Default + Extend, FromB: Default + Extend, Self: Sized + Iterator, ### Description Converts an iterator of pairs into a pair of containers. ``` -------------------------------- ### Compressor::zlib_compress_bound Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Compressor.html Returns the maximum number of bytes required to encode n_bytes as zlib data. ```APIDOC ## Compressor::zlib_compress_bound ### Description Returns the maximum number of bytes required to encode `n_bytes` as `zlib` data. This is a hard upper-bound that assumes the worst possible compression ratio (i.e. assumes the data cannot be compressed), format overhead, etc. ### Signature ```rust pub fn zlib_compress_bound(&mut self, n_bytes: usize) -> usize ``` ### Parameters * `n_bytes` (usize) - The number of bytes to compress. ``` -------------------------------- ### all Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Tests if every element of the iterator matches a predicate. ```APIDOC ## fn all(&mut self, f: F) -> bool ### Description Tests if every element of the iterator matches a predicate. ### Parameters - **f** (F) - A closure that takes an item and returns a boolean. ``` -------------------------------- ### fuse Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Creates an iterator which ends after the first `None`. ```APIDOC ## fn fuse(self) -> Fuse ### Description Creates an iterator which ends after the first `None`. ``` -------------------------------- ### Decompress Zlib Data in Rust Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Decompresses zlib data from an input buffer to an output buffer. Returns the number of decompressed bytes or a DecompressionError. ```rust pub fn zlib_decompress(&mut self, zlib_data: &[u8], out: &mut [u8]) -> DecompressionResult { unsafe { let mut out_nbytes = 0; let in_ptr = zlib_data.as_ptr() as *const std::ffi::c_void; let out_ptr = out.as_mut_ptr() as *mut std::ffi::c_void; let ret: libdeflate_result = libdeflate_zlib_decompress(self.p.as_ptr(), in_ptr, zlib_data.len(), out_ptr, out.len(), ``` -------------------------------- ### Compressor::gzip_compress_bound Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Compressor.html Returns the maximum number of bytes required to encode n_bytes as gzip data. ```APIDOC ## Compressor::gzip_compress_bound ### Description Returns the maximum number of bytes required to encode `n_bytes` as `gzip` data. This is a hard upper-bound that assumes the worst possible compression ratio (i.e. assumes the data cannot be compressed), format overhead, etc. ### Signature ```rust pub fn gzip_compress_bound(&mut self, n_bytes: usize) -> usize ``` ### Parameters * `n_bytes` (usize) - The number of bytes to compress. ``` -------------------------------- ### Into Trait Implementation for Decompressor Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Decompressor.html Implements the `into` method, which converts the type into another type via the `From` trait. ```rust fn into(self) -> U ``` -------------------------------- ### Decompression Operations Source: https://docs.rs/libdeflater/1.25.2/libdeflater/index.html The Decompressor struct allows for the decompression of DEFLATE, zlib, and gzip data. It requires pre-allocated input and output buffers. Ensure the output buffer is large enough to avoid `DecompressionError::InsufficientSpace`. ```APIDOC ## Decompression `Decompressor::new` can be used to construct a `Decompressor`, which can decompress: * DEFLATE data (`deflate_decompress`) * zlib data (`zlib_decompress`) * gzip data (`gzip_decompress`) **Note** : `libdeflate` requires that the input _and_ output buffers are pre-allocated before decompressing. Because of this, you will at least need to know the upper bound on how large the compressed data will decompress to; otherwise, a `decompress_*` function call will return `DecompressionError::InsufficientSpace` ``` -------------------------------- ### collect Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Transforms an iterator into a collection. ```APIDOC ## fn collect(self) -> B ### Description Transforms an iterator into a collection. ### Type Parameters - **B**: Must implement `FromIterator`. ``` -------------------------------- ### try_find Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Applies a function to the elements of an iterator and returns the first true result or the first error. This is a nightly-only experimental API. ```APIDOC ## fn try_find( &mut self, f: impl FnMut(&Self::Item) -> R, ) -> <::Residual as Residual>>::TryType where Self: Sized, R: Try, ::Residual: Residual>, ### Description Applies function to the elements of iterator and returns the first true result or the first error. ### Note This is a nightly-only experimental API. ``` -------------------------------- ### Adler32 Checksum Calculation Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Provides functionality to calculate Adler32 checksums, including rolling checksums. ```APIDOC ## Adler32::new ### Description Returns a new `Adler32` instance with the default initial value of 1. ### Method `pub const fn new() -> Adler32` ### Return Value - `Adler32`: A new Adler32 instance. ``` ```APIDOC ## Adler32::with_initial ### Description Returns a new `Adler32` instance with a specified initial value. ### Method `pub const fn with_initial(val: u32) -> Adler32` ### Parameters - `val` (u32): The initial Adler32 value. ### Return Value - `Adler32`: A new Adler32 instance with the specified initial value. ``` ```APIDOC ## Adler32::update ### Description Updates the Adler32 checksum with the provided data. ### Method `pub fn update(&mut self, data: &[u8])` ### Parameters - `data` (&[u8]): The data to update the Adler32 checksum with. ``` -------------------------------- ### From Trait Implementation for Decompressor Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Decompressor.html Implements the `from` method, which returns the argument unchanged. This is a standard conversion trait. ```rust fn from(t: T) -> T ``` -------------------------------- ### From for T Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvl.html Implementation of the `From` trait for converting a type into itself. ```APIDOC ### impl From for T #### fn from(t: T) -> T ### Description Returns the argument unchanged. ``` -------------------------------- ### Compressor::deflate_compress_bound Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Compressor.html Returns the maximum number of bytes required to encode n_bytes as deflate data. ```APIDOC ## Compressor::deflate_compress_bound ### Description Returns the maximum number of bytes required to encode `n_bytes` as `deflate` data. This is a hard upper-bound that assumes the worst possible compression ratio (i.e. assumes the data cannot be compressed), format overhead, etc. ### Signature ```rust pub fn deflate_compress_bound(&mut self, n_bytes: usize) -> usize ``` ### Parameters * `n_bytes` (usize) - The number of bytes to compress. ``` -------------------------------- ### cmp Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Lexicographically compares the elements of this `Iterator` with those of another. ```APIDOC ## fn cmp(self, other: I) -> Ordering where I: IntoIterator, Self::Item: Ord, Self: Sized, ### Description Lexicographically compares the elements of this `Iterator` with those of another. ``` -------------------------------- ### position Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Searches for an element in an iterator, returning its index. ```APIDOC ## fn position

(&mut self, predicate: P) -> Option where Self: Sized, P: FnMut(Self::Item) -> bool, ### Description Searches for an element in an iterator, returning its index. ``` -------------------------------- ### min_by Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Returns the element that gives the minimum value with respect to the specified comparison function. ```APIDOC ## fn min_by(self, compare: F) -> Option where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering, ### Description Returns the element that gives the minimum value with respect to the specified comparison function. ``` -------------------------------- ### TryFrom Trait Implementation for Decompressor Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.Decompressor.html Implements the `try_from` method for fallible conversions between types. ```rust fn try_from(value: U) -> Result>::Error> ``` -------------------------------- ### Free Decompressor Resources Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Frees the resources associated with a decompressor instance when it is dropped. This ensures proper memory management. ```rust unsafe { libdeflate_free_decompressor(self.p.as_ptr()); } ``` -------------------------------- ### Adler32 struct Source: https://docs.rs/libdeflater/1.25.2/src/libdeflater/lib.rs.html Represents a rolling Adler32 checksum calculator. ```APIDOC ## Adler32 ### Description Provides functionality to compute Adler32 checksums incrementally. ### Methods #### `new()` Creates a new `Adler32` instance with an initial checksum of 1. #### `update(data: &[u8])` Updates the Adler32 checksum with the provided data slice. #### `sum()` Returns the current Adler32 checksum as a `u32`. ``` -------------------------------- ### Adler32 Checksum Source: https://docs.rs/libdeflater/1.25.2/index.html Calculates the Adler32 checksum of the provided data. ```APIDOC ## Functions§ adler32 Returns the Adler32 checksum of the bytes in `data`. ``` -------------------------------- ### partial_cmp Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Lexicographically compares the `PartialOrd` elements of this `Iterator` with those of another. The comparison works like short-circuit evaluation, returning a result without comparing the remaining elements. As soon as an order can be determined, the evaluation stops and a result is returned. ```APIDOC ## fn partial_cmp(self, other: I) -> Option where I: IntoIterator, Self::Item: PartialOrd<::Item>, Self: Sized, ### Description Lexicographically compares the `PartialOrd` elements of this `Iterator` with those of another. The comparison works like short-circuit evaluation, returning a result without comparing the remaining elements. As soon as an order can be determined, the evaluation stops and a result is returned. ``` -------------------------------- ### collect_into Source: https://docs.rs/libdeflater/1.25.2/libdeflater/struct.CompressionLvlIter.html Collects all the items from an iterator into a collection. ```APIDOC ## fn collect_into(self, collection: &mut E) -> &mut E ### Description Collects all the items from an iterator into a collection. ### Parameters - **collection**: A mutable reference to the collection to extend. ```