Skip to content

Commit

Permalink
dbgln--
Browse files Browse the repository at this point in the history
  • Loading branch information
fasterthanlime committed Dec 18, 2024
1 parent 9f53c32 commit 7c66b9e
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions rc-zip-monoio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,55 +13,31 @@ use rc_zip::{
parse::Archive,
};

macro_rules! dbgln {
($($tt:tt)*) => {
// eprintln!($($tt)*);
};
}

pub async fn read_zip_from_file(file: &File) -> Result<Archive, Error> {
dbgln!("Starting to read zip from file...");
let meta = file.metadata().await?;
let size = meta.len();
dbgln!("File size: {size}");
let mut buf = vec![0u8; 256 * 1024].into_boxed_slice();

let mut fsm = ArchiveFsm::new(size);

Check warning on line 21 in rc-zip-monoio/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

rc-zip-monoio/src/lib.rs#L16-L21

Added lines #L16 - L21 were not covered by tests
loop {
dbgln!("Entering loop...");
if let Some(offset) = fsm.wants_read() {
dbgln!("FSM wants read at offset: {offset}");
let dst = fsm.space();
let max_read = dst.len().min(buf.len());
dbgln!(
"Calculated max_read: {max_read}, dst.len: {}, buf.len: {}",
dst.len(),
buf.len()
);
let slice = IoBufMut::slice_mut(buf, 0..max_read);

Check warning on line 26 in rc-zip-monoio/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

rc-zip-monoio/src/lib.rs#L23-L26

Added lines #L23 - L26 were not covered by tests

let (res, slice) = file.read_at(slice, offset).await;
dbgln!("Read result: {:?}", res);
let n = res?;
dbgln!("Number of bytes read: {n}");
(dst[..n]).copy_from_slice(&slice[..n]);

fsm.fill(n);
dbgln!("FSM filled with {n} bytes");
buf = slice.into_inner();
} else {
dbgln!("FSM does not want to read more data.");
}

Check warning on line 34 in rc-zip-monoio/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

rc-zip-monoio/src/lib.rs#L28-L34

Added lines #L28 - L34 were not covered by tests

fsm = match fsm.process()? {
FsmResult::Done(archive) => {
dbgln!("FSM processing done.");
break Ok(archive);

Check warning on line 38 in rc-zip-monoio/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

rc-zip-monoio/src/lib.rs#L36-L38

Added lines #L36 - L38 were not covered by tests
}
FsmResult::Continue(fsm) => {
dbgln!("FSM wants to continue.");
fsm
}
FsmResult::Continue(fsm) => fsm,

Check warning on line 40 in rc-zip-monoio/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

rc-zip-monoio/src/lib.rs#L40

Added line #L40 was not covered by tests
}
}
}

Check warning on line 43 in rc-zip-monoio/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

rc-zip-monoio/src/lib.rs#L43

Added line #L43 was not covered by tests

0 comments on commit 7c66b9e

Please sign in to comment.