Skip to main content

parse_forward_preamble

Function parse_forward_preamble 

Source
pub fn parse_forward_preamble(
    preamble_bytes: &[u8],
    pos: u64,
    file_size: u64,
    bound: u64,
) -> ForwardOutcome
Expand description

Parse a forward preamble fetch.

pos is the absolute byte offset where this preamble begins; file_size caps the message-end against the known total file length; bound is the soft cap (prev_scan_offset in bidirectional mode, file_size in forward-only mode).

Pure function — does not touch any backend state.

use tensogram::remote_scan_parse::{ForwardOutcome, parse_forward_preamble};
// Buffer too short.
let outcome = parse_forward_preamble(&[0u8; 4], 0, 1024, 1024);
assert!(matches!(outcome, ForwardOutcome::Terminate { reason: "short-fetch-fwd" }));