global: snap

This commit is contained in:
nym21
2026-04-15 13:04:22 +02:00
parent 08ba4ad996
commit c23e0f2a3c
10 changed files with 90 additions and 261 deletions
+4 -8
View File
@@ -6,9 +6,9 @@ use crate::{XORBytes, XORIndex, xor_bytes::XOR_LEN};
const MAGIC_BYTES: [u8; 4] = [0xF9, 0xBE, 0xB4, 0xD9];
/// Returns the position **immediately after** the matched magic, or
/// Returns the position immediately after the matched magic, or
/// `None` if no match. Advances `xor_i` by the bytes consumed either
/// way. First-byte fast-fail keeps the inner loop tight.
/// way.
pub(crate) fn find_magic(bytes: &[u8], xor_i: &mut XORIndex, xor_bytes: XORBytes) -> Option<usize> {
let len = bytes.len();
if len < MAGIC_BYTES.len() {
@@ -42,17 +42,13 @@ pub(crate) fn find_magic(bytes: &[u8], xor_i: &mut XORIndex, xor_bytes: XORBytes
None
}
/// Position (relative to `buf`) of the first matched magic byte.
/// Used by the chunked tail pipeline to carry pre-first-magic bytes
/// into the next (earlier) chunk.
pub(crate) struct ScanResult {
pub first_magic: Option<usize>,
}
/// Scans `buf` for blocks and calls `on_block` for each. `file_offset`
/// is the absolute file position of `buf[0]` used to seed the XOR
/// phase and to report absolute `BlkPosition`s so the chunked tail
/// pipeline can read mid-file slices.
/// is the absolute file position of `buf[0]`, used to seed the XOR
/// phase and to report absolute `BlkPosition`s.
pub(crate) fn scan_bytes(
buf: &mut [u8],
blk_index: u16,