Expand description

Simple tools for reading and writing crc-checked frames of bytes.

  • Uses crc32fast for a 4-byte crc
  • Uses varint for frame sizing
  • Tested against libfuzzer

The varint module is also public for direct use.

Modules

Variable-length encoding of u64

Functions

Return an array which contains the crc and varint for a given buffer, and a usize that is the length of the provided array which corresponds to the valid varint and crc. Returns an array instead of a Vec to avoid allocations.

Reads a header out of an arbitrary buffer, checks the crc, and if the crc matches the corresponding bytes, returns the start and end offsets in the buffer for the inner bytes.

Read a frame out of the provided Read implementation.

Read a frame out of the provided File

Write a crc’d frame into the provided Write instance. Returns the number of bytes written in total, including the varint size and crc.

Write a crc’d frame into the provided File at the given offset. Returns the number of bytes written in total, including the varint size and crc.