1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use crate::*;
/// Compresses the given data using Gzip compression.
///
/// This function takes a byte slice of data and compresses it using the Gzip compression algorithm.
/// If the compression succeeds, the resulting compressed data is returned as a `Cow<Vec<u8>>`.
/// If any error occurs during the compression process, an empty `Vec<u8>` is returned.
///
/// # Parameters
/// - `data` - A reference to a byte slice (`&[u8]`) containing the data to be compressed.
///
/// # Returns
/// - `Cow<[u8]>` - The compressed data as a `Cow<[u8]>`. The compressed data is returned as an
/// owned `Vec<u8>`. If compression fails, an empty owned `Vec<u8>` is returned.
/// Decompresses the given data using the specified decompressor.
///
/// This function takes a byte slice of compressed data and decompresses it using
/// a decompressor, returning the result as a `Cow<Vec<u8>>`. If decompression is successful,
/// the decompressed data is returned as an owned `Vec<u8>`. In case of an error, an empty
/// `Vec<u8>` is returned.
///
/// # Parameters
/// - `data` - A reference to a byte slice (`&[u8]`) containing the compressed data to be decoded.
/// - `buffer_size` - The buffer size to use for the decompression process. A larger buffer size can
/// improve performance for larger datasets.
///
/// # Returns
/// - `Cow<[u8]>` - The decompressed data as a `Cow<[u8]>`. If decompression is successful, the
/// decompressed data is returned as an owned `Vec<u8>`. In case of an error, an empty owned
/// `Vec<u8>` is returned.