Hi,
This is a cross-post from Reading a file entry (newbie question) - trying to use the examples · Issue #14 · rust-compress/rc-zip · GitHub.
I'm trying to read an XML in a ZIP file (via rc-zip) and connecting the file I'm reading from the zip to my quick xml reader without using an intermediate file (or storing the entire contents in memory - since the XML unzipped is huge).
The closest I've come is:
let entry_reader = c.entry.reader(|offset| positioned_io::Cursor::new_pos(&zipfile, offset)).take(c.entry.compressed_size)
Which gives me a Take<EntryReader<Cursor<...>>>
. From my understanding of positioned io cursors and Take I should be able to read it (for example via read
) but I want to process it as a buffer.
let buffer = c.entry.reader(|offset| positioned_io::Cursor::new_pos(&zipfile, offset)).take(c.entry.compressed_size)
let buffer = BufReader::new(buffer);
let mut reader = Reader::from_reader(buffer);
let mut buf = Vec::new();
match reader.read_event(&mut buf) {
....
}
Gives me:
^^^^^^ the trait `BufRead` is not implemented for `&std::io::Take<T>`
Now I've been scouring docs.rs for positioned io, io::Take and rc-zip but honestly the auto-generated docs is still pretty much greek to me too much lifecycle and stuff which I still don't (yet) understand.
Offer on Github stands: I will happily send a beer tip to whoever can help me solve this
Regards,
Niklas