Handling the frame itself
You are reaching the end of the frame parsing! It is time to put the various bits together.
Building the type
✅ Make the
frame::ZstandardFramestructure contain three fields: the frame header, a vector of blocks, and an optional checksum (au32).
Parsing
✅ Implement
ZstandardFrame::parse()and call it fromFrame::parse()in the presence of a Zstandard frame.
This method will need to:
- parse the header;
- parse the blocks (there is at least one), and continue doing so as long as the parsed block is not the last one;
- parse the checksum (a 32 bit little-endian value) if it is present according to the frame header descriptor.
The RFC limits the size of a block to the smallest of the window size and 128 KiB. You may want to pass this maximum block size to Block::parse() so that it can reject oversized blocks early with a dedicated error, before attempting to read a huge slice from the input.
Decoding
✅ Implement
ZstandardFrame::decode()and call it fromFrame::decode()in the presence of a Zstandard frame.
Decoding a frame means decoding each block in turn and concatenating the results. Return an error first if the frame header carries a dictionary ID, as dictionaries are not supported. The checksum will be verified later, once compressed blocks are handled.