use std::io::{self, Cursor, Read};
use flate2::{
bufread::{GzDecoder, GzEncoder},
Compression,
};
pub fn pack_gzip<S>(d: S) -> io::Result<Vec<u8>>
where
S: AsRef<[u8]>,
{
let mut gz = GzEncoder::new(Cursor::new(d), Compression::new(6));
let mut encoded = Vec::new();
gz.read_to_end(&mut encoded)?;
Ok(encoded)
}
pub fn unpack_gzip<S>(d: S) -> io::Result<Vec<u8>>
where
S: AsRef<[u8]>,
{
let mut gz = GzDecoder::new(Cursor::new(d));
let mut decoded = Vec::new();
gz.read_to_end(&mut decoded)?;
Ok(decoded)
}