Skip to main content

find_frame_compressed_size

Function find_frame_compressed_size 

Source
pub fn find_frame_compressed_size(src: &[u8]) -> Result<usize, FrameSizeError>
Expand description

On-disk byte length of the FIRST frame in src — magic number, frame header, every block, and the trailing content checksum when present — computed by walking the block headers without decoding any block body.

For a skippable frame, returns its full 8 + Frame_Size length. This backs the C ZSTD_findFrameCompressedSize entry point; the returned value is the offset at which a following concatenated frame would begin.

§Errors

FrameSizeError when the header is unreadable, the buffer is truncated mid-frame, or a block uses the reserved type.

use structured_zstd::encoding::{compress_slice_to_vec, CompressionLevel};
use structured_zstd::decoding::find_frame_compressed_size;
let frame = compress_slice_to_vec(&[5u8; 256], CompressionLevel::Default);
assert_eq!(find_frame_compressed_size(&frame).unwrap(), frame.len());