Skip to main content

check_inventory

Function check_inventory 

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

The structural inventory is honest and complete.

For a decoder that declares inventory:

  • inventory(valid) succeeds, for the decoder’s format, covering exactly valid.len() bytes, passing Inventory::validate, and attributing at least one part to ImageData;
  • with 37 junk bytes appended, the inventory still validates, still covers the whole input, and attributes every appended byte to an unconsumed part: junk must never be reported as structure, image data or metadata;
  • every truncation of valid yields a valid inventory without panicking or failing, because truncated and malformed input is exactly what an audit needs to see.

A decoder that does not declare the capability must return an unsupported-inventory error.

valid must be a complete file with a logical end (JPEG EOI, PNG IEND, the last box). On a stream that is already cut short, appended bytes can legitimately continue the cut unit (a JPEG scan without EOI reads them as scan data), so the junk assertion doesn’t apply: for such corpus files call Inventory::validate directly.