Skip to main content

Chunk

Enum Chunk 

Source
pub enum Chunk {
    Form {
        secondary_id: ChunkId,
        length: u32,
        children: Vec<Chunk>,
    },
    Leaf {
        id: ChunkId,
        data: Vec<u8>,
    },
}
Expand description

A parsed IFF chunk — either a FORM container or a leaf data chunk.

Variants§

§

Form

A FORM container with a secondary ID and child chunks.

Fields

§secondary_id: ChunkId

The secondary ID (e.g., b“DJVU“, b“DJVM“, b“DJVI“, b“THUM“).

§length: u32

Total byte length of the FORM payload (from the IFF length field). Includes the 4-byte secondary ID and all child chunk bytes.

§children: Vec<Chunk>

Child chunks within this FORM.

§

Leaf

A leaf chunk with raw data.

Fields

§id: ChunkId

The chunk ID (e.g., b“INFO“, b“Sjbz“, b“BG44“).

§data: Vec<u8>

The raw chunk payload bytes.

Implementations§

Source§

impl Chunk

Source

pub fn data(&self) -> &[u8]

For leaf chunks, return the data slice. For FORM chunks, returns empty slice.

Source

pub fn children(&self) -> &[Chunk]

For FORM chunks, return children. For leaf chunks, returns empty slice.

Source

pub fn payload_length(&self) -> u32

Return the declared payload length from the IFF length field.

For Form chunks, this is the value read from the IFF header — it covers the secondary ID (4 bytes) and all children. For Leaf chunks, this equals data().len().

Source

pub fn find_first(&self, target_id: &[u8; 4]) -> Option<&Chunk>

Find the first leaf chunk with the given ID in direct children.

Source

pub fn find_all(&self, target_id: &[u8; 4]) -> Vec<&Chunk>

Find all leaf chunks with the given ID in direct children.

Trait Implementations§

Source§

impl Clone for Chunk

Source§

fn clone(&self) -> Chunk

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 Chunk

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Chunk

§

impl RefUnwindSafe for Chunk

§

impl Send for Chunk

§

impl Sync for Chunk

§

impl Unpin for Chunk

§

impl UnsafeUnpin for Chunk

§

impl UnwindSafe for Chunk

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.