Skip to main content

frame_magic

Function frame_magic 

Source
pub fn frame_magic(src: &[u8]) -> Option<FrameMagic>
Expand description

Which frame src starts with, judged by its magic number alone. Backs the C ZSTD_isFrame / ZSTD_isSkippableFrame. None when src is shorter than four bytes or the magic is no frame’s.

use structured_zstd::decoding::{frame_magic, FrameMagic};
assert_eq!(frame_magic(&[0x28, 0xB5, 0x2F, 0xFD]), Some(FrameMagic::Zstd));
assert_eq!(frame_magic(&[0x53, 0x2A, 0x4D, 0x18]), Some(FrameMagic::Skippable(3)));
assert_eq!(frame_magic(b"zip"), None);