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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use crate::*;
/// Compresses the given data using Gzip compression.
///
/// This function takes a byte slice of data and compresses it using the `GzEncoder` from the `flate2` crate.
/// The compression is done in a buffered manner to optimize performance. If compression is successful,
/// the result is returned as an owned `Vec<u8>`. If an error occurs during compression, an empty `Vec<u8>`
/// is returned.
///
/// # Arguments
///
/// - `data` - A reference to a byte slice (`&[u8]`) containing the data to be compressed.
/// - `buffer_size` - The buffer size to use for the buffered writer. A larger buffer size can improve
/// performance for larger datasets.
///
/// # Returns
///
/// - `Cow<[u8]>` - The compressed data as a `Cow<[u8]>`. If compression is successful, the
/// compressed data is returned as an owned `Vec<u8>`. If an error occurs, an empty owned `Vec<u8>`
/// is returned.
/// Decompresses the given Gzip-compressed data.
///
/// This function takes a byte slice of Gzip-compressed data and decompresses it using the `GzDecoder`
/// from the `flate2` crate. The decompression is done in a buffered manner to optimize performance.
/// If decompression is successful, the result is returned as an owned `Vec<u8>`. If an error occurs
/// during decompression, an empty `Vec<u8>` is returned.
///
/// # Arguments
///
/// - `data` - A reference to a byte slice (`&[u8]`) containing the Gzip-compressed data.
/// - `buffer_size` - The buffer size to use for the buffered reader. 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>`. If an error occurs, an empty owned `Vec<u8>`
/// is returned.