mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-30 12:18:11 -07:00
global: snap
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user