Skip to main content

patch_section_crc

Function patch_section_crc 

Source
pub fn patch_section_crc(
    bytes: &mut [u8],
    kind: u32,
    checksum: Checksum32,
) -> Result<(), SnapshotError>
Expand description

Recomputes and patches one section’s entry CRC-32C (and the header’s table_crc32c, which covers that entry) in already-encoded snapshot bytes.

This is the escape hatch for producers that must patch a section’s payload after encoding — e.g. a trailer whose payload is derived from the encoded bytes themselves. After mutating the payload in place, call this to restore the checksum invariants for that section and the table. All other entries are left untouched.

§Errors

Returns any structural SnapshotError from Snapshot::open, or SnapshotError::SectionMissing when no section has kind.

§Performance

This function is O(s + section payload bytes): one structural open, one fold over the section’s payload, and one fold over the table bytes.