Skip to main content

read_frame_header_info

Function read_frame_header_info 

Source
pub fn read_frame_header_info(
    src: &[u8],
    magicless: bool,
) -> Result<FrameHeaderInfo, ReadFrameHeaderError>
Expand description

Decode the leading frame header fields of src without decoding the body.

Backs the C ZSTD_getFrameHeader. When magicless is true the 4-byte magic prefix is assumed absent (the ZSTD_f_zstd1_magicless format); the caller must know out-of-band that the stream is magicless. The reported FrameHeaderInfo::window_size is the raw value derived from the header (no maximum-window policy applied here; that bound is enforced at decode time), so callers see the frame’s own declared window even when it exceeds a decoder limit.

§Errors

As read_frame_content_size.

use structured_zstd::encoding::{compress_slice_to_vec, CompressionLevel};
use structured_zstd::decoding::{read_frame_header_info, FrameContentSize};
let frame = compress_slice_to_vec(&[7u8; 512], CompressionLevel::Default);
let info = read_frame_header_info(&frame, false).unwrap();
assert_eq!(info.content_size, FrameContentSize::Known(512));
assert!(info.window_size >= 512);