pub fn validate_parse(
sequences: &[ExternalSequence],
src_len: usize,
window: u64,
dict_len: usize,
explicit_delimiters: bool,
max_block: usize,
) -> Result<(), SequenceError>Expand description
Check that sequences is a parse of src_len bytes a decoder can follow:
every match at least MIN_MATCH bytes (literals with no match are a
delimiter, offset 0), every
offset within what is decoded so far plus dict_len bytes of dictionary
while that fits the window, and within window after. With
explicit_delimiters the parse must cover the input exactly and each
delimited block hold at most max_block bytes; without, bytes past the
parse are trailing literals.
use structured_zstd::encoding::sequences::{validate_parse, ExternalSequence, SequenceError};
let parse = [ExternalSequence { offset: 3, lit_len: 3, match_len: 6, rep: 0 }];
assert_eq!(validate_parse(&parse, 12, 1 << 20, 0, false, 1 << 17), Ok(()));
let reaching = [ExternalSequence { offset: 9, lit_len: 3, match_len: 6, rep: 0 }];
assert_eq!(
validate_parse(&reaching, 12, 1 << 20, 0, false, 1 << 17),
Err(SequenceError::OffsetTooFar { index: 0 })
);