-
use std::io::prelude::*;
use std::io;
use flate2::bufread::MultiGzDecoder;
use std::io::BufReader;
use std::fs::File;
// Uncompresses a Gz Encoded vector of bytes and returns a string or error
// Here &[u8] implements BufRead
fn decode_reader(bytes: Vec<u8>) -> io::Result<String> {
let mut gz = MultiGzDecoder::new(
BufReader::new(File::open("some.gz").unwrap());
);
let mut gz = BufReader::new(gz); // << Is this proper way?
// ...
gz.read_until(...);
gz.read_line(...);
todo!()
}Is just making a new |
Beta Was this translation helpful? Give feedback.
Answered by
jongiddy
Jun 2, 2024
Replies: 1 comment
-
|
Yes, this is the correct way. The first |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Crispy13
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, this is the correct way. The first
BufReaderwraps the input data read from the file, allowingbufread::GzDecoderto call theBufReadmethods on the compressed data. The secondBufReaderwraps the output data, allowing you to call theBufReadmethods on the decompressed data.