| 1 | //! Compress and decompress data in bulk. |
| 2 | //! |
| 3 | //! These methods process all the input data at once. |
| 4 | //! It is therefore best used with relatively small blocks |
| 5 | //! (like small network packets). |
| 6 | |
| 7 | mod compressorrust-analyzer cargo zstd 0.13.3 bulk/compressor/; |
| 8 | mod decompressorrust-analyzer cargo zstd 0.13.3 bulk/decompressor/; |
| 9 | |
| 10 | #[cfg(test)] |
| 11 | mod testsrust-analyzer cargo zstd 0.13.3 bulk/tests/; |
| 12 | |
| 13 | pub use selfrust-analyzer cargo zstd 0.13.3 bulk/::compressorrust-analyzer cargo zstd 0.13.3 bulk/compressor/::Compressorrust-analyzer cargo zstd 0.13.3 bulk/compressor/Compressor#; |
| 14 | pub use selfrust-analyzer cargo zstd 0.13.3 bulk/::decompressorrust-analyzer cargo zstd 0.13.3 bulk/decompressor/::Decompressorrust-analyzer cargo zstd 0.13.3 bulk/decompressor/Decompressor#; |
| 15 | |
| 16 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/; |
| 17 | |
| 18 | /// Compresses a single block of data to the given destination buffer. |
| 19 | /// |
| 20 | /// Returns the number of bytes written, or an error if something happened |
| 21 | /// (for instance if the destination buffer was too small). |
| 22 | /// |
| 23 | /// A level of `0` uses zstd's default (currently `3`). |
| 24 | pub fn compress_to_bufferrust-analyzer cargo zstd 0.13.3 bulk/compress_to_buffer().( |
| 25 | source: &[u8], |
| 26 | destination: &mut [u8], |
| 27 | level: i32, |
| 28 | ) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> { |
| 29 | Compressorrust-analyzer cargo zstd 0.13.3 bulk/compressor/Compressor#::newrust-analyzer cargo zstd 0.13.3 bulk/compressor/impl#[`Compressor<'static>`]new().(level)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..compress_to_bufferrust-analyzer cargo zstd 0.13.3 bulk/compressor/impl#[`Compressor<'a>`]compress_to_buffer().(source, destination) |
| 30 | } |
| 31 | |
| 32 | /// Compresses a block of data and returns the compressed result. |
| 33 | /// |
| 34 | /// A level of `0` uses zstd's default (currently `3`). |
| 35 | pub fn compressrust-analyzer cargo zstd 0.13.3 bulk/compress().(data: &[u8], level: i32) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>> { |
| 36 | Compressorrust-analyzer cargo zstd 0.13.3 bulk/compressor/Compressor#::newrust-analyzer cargo zstd 0.13.3 bulk/compressor/impl#[`Compressor<'static>`]new().(level)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..compressrust-analyzer cargo zstd 0.13.3 bulk/compressor/impl#[`Compressor<'a>`]compress().(data) |
| 37 | } |
| 38 | |
| 39 | /// Deompress a single block of data to the given destination buffer. |
| 40 | /// |
| 41 | /// Returns the number of bytes written, or an error if something happened |
| 42 | /// (for instance if the destination buffer was too small). |
| 43 | pub fn decompress_to_bufferrust-analyzer cargo zstd 0.13.3 bulk/decompress_to_buffer().( |
| 44 | source: &[u8], |
| 45 | destination: &mut [u8], |
| 46 | ) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> { |
| 47 | Decompressorrust-analyzer cargo zstd 0.13.3 bulk/decompressor/Decompressor#::newrust-analyzer cargo zstd 0.13.3 bulk/decompressor/impl#[`Decompressor<'static>`]new().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..decompress_to_bufferrust-analyzer cargo zstd 0.13.3 bulk/decompressor/impl#[`Decompressor<'a>`]decompress_to_buffer().(source, destination) |
| 48 | } |
| 49 | |
| 50 | /// Decompresses a block of data and returns the decompressed result. |
| 51 | /// |
| 52 | /// The decompressed data should be at most `capacity` bytes, |
| 53 | /// or an error will be returned. |
| 54 | pub fn decompressrust-analyzer cargo zstd 0.13.3 bulk/decompress().(data: &[u8], capacity: usize) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>> { |
| 55 | Decompressorrust-analyzer cargo zstd 0.13.3 bulk/decompressor/Decompressor#::newrust-analyzer cargo zstd 0.13.3 bulk/decompressor/impl#[`Decompressor<'static>`]new().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..decompressrust-analyzer cargo zstd 0.13.3 bulk/decompressor/impl#[`Decompressor<'a>`]decompress().(data, capacity) |
| 56 | } |