Closed Julian-Alberts closed 1 year ago
You need to call Encoder::finish()
as follows:
let mut encoded = Vec::new();
let mut encoder = libflate::gzip::Encoder::new(&mut encoded).unwrap();
encoder.write_all(b"Hello World").unwrap();
encoder.finish().unwrap();
assert!(encoded.len() > 0);
let mut decoded = Vec::default();
libflate::gzip::Decoder::new(encoded.as_slice())
.unwrap()
.read_to_end(&mut decoded)
.unwrap();
assert_eq!(decoded.as_slice(), b"Hello World")
Thanks, I don't know how I missed this.
While testing my code, I encountered an issue where encoded data could not be decoded.
The following example panics with the message "called
Result::unwrap()
on anErr
value: Error { kind: UnexpectedEof, message: "failed to fill whole buffer" }" at the last unwarp.libflate version 1.3.0 rust version 1.68.0