2021-12-02 13:01:44 +03:00
|
|
|
module zlib
|
|
|
|
|
2023-02-08 21:37:04 +03:00
|
|
|
import compress as compr
|
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
|
2023-06-13 19:10:27 +03:00
|
|
|
// Example: compressed := zlib.compress(b)!
|
2022-10-20 22:14:33 +03:00
|
|
|
pub fn compress(data []u8) ![]u8 {
|
2021-12-02 13:01:44 +03:00
|
|
|
// flags = TDEFL_WRITE_ZLIB_HEADER (0x01000)
|
2023-02-08 21:37:04 +03:00
|
|
|
return compr.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
|
2023-06-13 19:10:27 +03:00
|
|
|
// Example: decompressed := zlib.decompress(b)!
|
2022-10-20 22:14:33 +03:00
|
|
|
pub fn decompress(data []u8) ![]u8 {
|
2021-12-02 13:01:44 +03:00
|
|
|
// flags = TINFL_FLAG_PARSE_ZLIB_HEADER (0x1)
|
2023-02-08 21:37:04 +03:00
|
|
|
return compr.decompress(data, 0x1)
|
2021-12-02 13:01:44 +03:00
|
|
|
}
|