Skip to main content

FrameBlock

Struct FrameBlock 

Source
pub struct FrameBlock {
    pub offset_in_frame: u32,
    pub header_size: u8,
    pub body_size: u32,
    pub block_size_field: u32,
    pub block_type: BlockType,
    pub last_block: bool,
    pub decompressed_size: u32,
}
Available on crate feature lsm only.
Expand description

Layout of a single zstd block inside an emitted frame.

Offsets are absolute byte positions in the emitted-frame buffer: offset_in_frame points at the first byte of the 3-byte Block_Header, and the block body lives at offset_in_frame + header_size .. offset_in_frame + header_size + body_size. The arithmetic offset_in_frame + header_size as u32 + body_size is the byte offset of the next block (or, on the last block, of the trailing checksum / end of frame).

For RLE blocks the body_size is 1 (the single repeated byte on the wire); the spec’s Block_Size field carries the logical repeat count instead and is surfaced separately as block_size_field.

Fields§

§offset_in_frame: u32

Byte offset of this block’s Block_Header within the emitted frame buffer (frame-absolute, includes the bytes consumed by the frame header / magic / FCS that precede the first block).

§header_size: u8

Size of the Block_Header in bytes. Always 3 today; carried as a field so the API stays forward-compatible with any future spec extension that widens the header.

§body_size: u32

Physical length of this block’s body in bytes on the wire (does NOT include header_size). For Raw / Compressed blocks this is the number of bytes after the header; for RLE blocks this is always 1 (the repeated byte itself, while the spec’s Block_Size field encodes the logical repeat count — see block_size_field). The arithmetic offset_in_frame + header_size as u32 + body_size always lands on the next block boundary.

§block_size_field: u32

Raw Block_Size value from the 3-byte Block_Header. For Raw and Compressed blocks this equals body_size; for RLE blocks it’s the logical repeat count (how many bytes the single physical body byte expands to during decode) and will differ from body_size (which is 1).

§block_type: BlockType

Whether the block is Raw, RLE, or Compressed per RFC 8878 §3.1.1.2.1 (Block_Type).

§last_block: bool

true only on the final block of the frame (matches the Last_Block flag in Block_Header).

§decompressed_size: u32

Decompressed (regenerated) size of this block’s output in bytes.

For Raw and RLE blocks this is recoverable from the wire (block_size_field), but a Compressed block’s regenerated size is NOT in its Block_Header (the header’s Block_Size is the compressed length), so the encoder captures it from the input chunk that produced the block. Consumers map a decompressed byte offset to a block index via the prefix sum of this field; see FrameEmitInfo::decompressed_byte_range.

On the decode error path (FailedToReadBlockBodyAt), where the regenerated size of a failed Compressed block is unknown, this is 0 for Compressed blocks (Raw/RLE still carry their wire size).

Trait Implementations§

Source§

impl Clone for FrameBlock

Source§

fn clone(&self) -> FrameBlock

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FrameBlock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for FrameBlock

Source§

impl PartialEq for FrameBlock

Source§

fn eq(&self, other: &FrameBlock) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for FrameBlock

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.