Open
Description
A common use case is compressing a &[u8]
into a Vec<u8>
without doing any I/O. The current docs don't make it clear how to do this.
A google search turns up this forum post with this code snippet:
use std::io::Write;
pub fn compress(input: &[u8]) -> Vec<u8> {
let mut writer = brotli::CompressorWriter::new(
Vec::new(),
4096,
11,
22);
writer.write_all(input).unwrap();
writer.into_inner()
}
Which is nontrivial to figure out. A helper functions in the root of the crate to compress a &[u8]
into a Vec<u8>
and to decompress a Vec<u8>
into a &[u8]
would help a lot with this. (Also, if these functions don't do I/O then perhaps they could be be infallible.)
Metadata
Metadata
Assignees
Labels
No labels