From ade93550ad4f70871b52aace027421c37f261bd8 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Sun, 31 Dec 2023 00:20:56 +0200 Subject: [PATCH] do not consume iterator --- src/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f6990b4..6619b89 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -145,11 +145,14 @@ impl Iterator for Decoder { } pub fn decode_raw(filename: &str, frames_root: &str) -> anyhow::Result>> { - let packiter = PacketsIterator::new(filename)?; - let data = packiter.collect::>(); - // let (i, size) = (packiter.i, packiter.size); + let mut packiter = PacketsIterator::new(filename)?; + let mut data = vec![]; + while let Some(p) = packiter.next() { + data.push(p); + } + let (i, size) = (packiter.i, packiter.size); - //println!("found {} packets, saved {}, {} size", i, data.len(), size); + println!("found {} packets, saved {}, {} size", i, data.len(), size); let dump_filename = format!("{}/dump.bin", filename); let mut dump = File::create_new(dump_filename); let mut frames = vec![];