This crate contains a [
FallibleStreamingIterator] optimized for decompressions.
A typical problem that libraries working with compressed formats face is that they need to preserve an intermediary buffer to decompress multiple items. Specifically, implementations that use
are ineficient because they will need to allocate a new
Vec<u8> for every decompression, and this
allocation scales with the average decompressed size the items.
The typical solution for this problem is to offer
Such API avoids one allocation per item, but requires the user to deal with preserving
between iterations. Such pattern is not possible to achieve with [
Iterator] API atm.
This crate offers [
Decompressor], a [
FallibleStreamingIterator] that consumes an [
Iterator] of compressed items
that yields uncompressed items, maintaining an internal [
Vec<u8>] that is automatically re-used across items.
use ; // An item that is decompressable // A decompressed item // the decompression function. This could call LZ4, Snappy, etc.
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.