Skip to main content

check_incremental_contract

Function check_incremental_contract 

Source
pub fn check_incremental_contract<D: DecoderConfig>(
    dec: D,
    data: &[u8],
) -> Conformance
Expand description

Exercise a decoder’s IncrementalDecode contract through the erased decoder callers receive (dyn_incremental_decoder), against the one-shot pixels of data:

  • driven from a slice with windows of 1, 7 and 64 bytes and the whole file, the pixels, descriptor and Done dimensions match one-shot, the sink is begun once and finished, and rows reach a final-only sink each exactly once in increasing order;
  • an input at an offset the decoder did not request is ignored without error (nothing taken, still asking);
  • after Done, further steps return Done again and take nothing;
  • a stop that trips mid-decode yields Cancelled within one step, then Finished;
  • a sink that accepts provisional rows still gets every final row once through provide_next_buffer (never through provide_pass_buffer), reproducing the one-shot pixels;
  • truncated input (cut at a quarter and at half) behaves as the one-shot decoder does on the same bytes: a codec error where it fails (never a protocol violation), the same pixels where it succeeds;
  • no drive exceeds a step budget, so a decoder that spins fails here instead of hanging.