pub fn parse_reproduces(
sequences: &[ExternalSequence],
src: &[u8],
dict: &[u8],
) -> Result<(), SequenceError>Expand description
Check that sequences decodes to src: every match copies the bytes the
input holds where it lands, out of src itself or, reaching before the
start, out of the tail of dict. A parse that validate_parse accepts
can still describe different bytes; compressing it would make a frame that
decodes to them, not to src.
The decoder has rebuilt the input up to each match, so the input stands for the output it copies from, overlapping copies included.
§Errors
SequenceError::MatchMismatch for the first match that copies other
bytes, SequenceError::LengthMismatch or SequenceError::OffsetTooFar
for a parse validate_parse would also refuse.
use structured_zstd::encoding::sequences::{parse_reproduces, ExternalSequence, SequenceError};
let parse = [ExternalSequence { offset: 3, lit_len: 3, match_len: 3, rep: 0 }];
assert_eq!(parse_reproduces(&parse, b"abcabc", &[]), Ok(()));
assert_eq!(
parse_reproduces(&parse, b"abcabd", &[]),
Err(SequenceError::MatchMismatch { index: 0 })
);