pub struct FrameEmitInfo {
pub frame_header_range: Range<u32>,
pub blocks: Vec<FrameBlock>,
pub checksum_range: Option<Range<u32>>,
pub total_size: u32,
}lsm only.Expand description
Complete layout of an emitted zstd frame.
Captures the byte positions of the frame header, every block, and
the optional trailing content checksum. The ranges are u32 byte
offsets into the emitted buffer (compressed_data sink of
FrameCompressor).
Fields§
§frame_header_range: Range<u32>Byte range of the frame header (magic number + frame-header fields). For magicless frames the magic is omitted but the range still starts at offset 0.
blocks: Vec<FrameBlock>One entry per emitted block, in stream order. The last entry
has last_block = true.
checksum_range: Option<Range<u32>>Byte range of the trailing 4-byte content checksum (XXH64
truncated to low 32 bits). None if the frame was emitted
without content_checksum.
total_size: u32Total emitted frame size in bytes (one past the last byte of the frame).
Implementations§
Source§impl FrameEmitInfo
impl FrameEmitInfo
Sourcepub fn decompressed_byte_range(&self, block_index: usize) -> Option<Range<u64>>
pub fn decompressed_byte_range(&self, block_index: usize) -> Option<Range<u64>>
Half-open decompressed byte range [start, end) of blocks[block_index]
within the frame’s full decompressed output, computed as the prefix
sum of every preceding block’s FrameBlock::decompressed_size.
This is the mapping a range-query consumer uses to turn a
decompressed byte offset into the inner-block index needed by
FrameDecoder::decode_blocks_partial: find the first block whose
range contains the offset.
Returns None if block_index is out of bounds.
§Examples
use structured_zstd::encoding::frame_emit_info::{FrameBlock, FrameEmitInfo, BlockType};
let info = FrameEmitInfo {
frame_header_range: 0..6,
blocks: vec![
FrameBlock { offset_in_frame: 6, header_size: 3, body_size: 10,
block_size_field: 10, block_type: BlockType::Compressed,
last_block: false, decompressed_size: 100 },
FrameBlock { offset_in_frame: 19, header_size: 3, body_size: 20,
block_size_field: 20, block_type: BlockType::Compressed,
last_block: true, decompressed_size: 40 },
],
checksum_range: None,
total_size: 42,
};
assert_eq!(info.decompressed_byte_range(0), Some(0..100));
assert_eq!(info.decompressed_byte_range(1), Some(100..140));
assert_eq!(info.decompressed_byte_range(2), None);Trait Implementations§
Source§impl Clone for FrameEmitInfo
impl Clone for FrameEmitInfo
Source§fn clone(&self) -> FrameEmitInfo
fn clone(&self) -> FrameEmitInfo
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FrameEmitInfo
impl Debug for FrameEmitInfo
impl Eq for FrameEmitInfo
Source§impl PartialEq for FrameEmitInfo
impl PartialEq for FrameEmitInfo
Source§fn eq(&self, other: &FrameEmitInfo) -> bool
fn eq(&self, other: &FrameEmitInfo) -> bool
self and other values to be equal, and is used by ==.