2021-12-02 13:01:44 +03:00
|
|
|
module zlib
|
|
|
|
|
2022-06-03 09:00:11 +03:00
|
|
|
import compress
|
2021-12-02 13:01:44 +03:00
|
|
|
|
2022-01-07 14:28:50 +03:00
|
|
|
// compresses an array of bytes using zlib and returns the compressed bytes in a new array
|
2022-05-13 06:56:21 +03:00
|
|
|
// Example: compressed := zlib.compress(b)?
|
2022-04-15 15:35:35 +03:00
|
|
|
pub fn compress(data []u8) ?[]u8 {
|
2021-12-02 13:01:44 +03:00
|
|
|
// flags = TDEFL_WRITE_ZLIB_HEADER (0x01000)
|
2022-06-03 09:00:11 +03:00
|
|
|
return compress.compress(data, 0x01000)
|
2021-12-02 13:01:44 +03:00
|
|
|
}
|
|
|
|
|
2022-01-07 14:28:50 +03:00
|
|
|
// decompresses an array of bytes using zlib and returns the decompressed bytes in a new array
|
2022-05-13 06:56:21 +03:00
|
|
|
// Example: decompressed := zlib.decompress(b)?
|
2022-04-15 15:35:35 +03:00
|
|
|
pub fn decompress(data []u8) ?[]u8 {
|
2021-12-02 13:01:44 +03:00
|
|
|
// flags = TINFL_FLAG_PARSE_ZLIB_HEADER (0x1)
|
2022-06-03 09:00:11 +03:00
|
|
|
return compress.decompress(data, 0x1)
|
2021-12-02 13:01:44 +03:00
|
|
|
}
|