Function deltachat::tools::buf_compress
source · pub(crate) fn buf_compress(buf: &[u8]) -> Result<Vec<u8>>
Expand description
Compresses buf
to Vec
using brotli
.
Note that it handles an empty buf
as a special value that remains empty after compression,
otherwise brotli would add its metadata to it which is not nice because this function is used
for compression of strings stored in the db and empty strings are common there. This approach is
not strictly correct because nowhere in the brotli documentation is said that an empty buffer
can’t be a result of compression of some input, but i think this will never break.