ChunkNode

Struct ChunkNode 

Source
pub struct ChunkNode<'a> { /* private fields */ }
Expand description

A lightweight cursor pointing to a specific node in the dependency graph.

This struct contains the logic to read, decompress, and navigate from this node. It is a “view” into the ParcodeReader and holds a lifetime reference to it.

Implementations§

Source§

impl<'a> ChunkNode<'a>

Source

pub fn read_raw(&self) -> Result<Cow<'a, [u8]>>

Reads and decompresses the local payload of this chunk.

This returns Cow, so if no compression was used, it returns a direct reference to the mmap (Zero-Copy). If compressed, it allocates the decompressed buffer.

Source

pub fn children(&self) -> Result<Vec<Self>>

Returns a list of all direct child nodes.

This allows manual traversal of the dependency graph (e.g., iterating over specific shards). Note: This does not deserialize the children, only loads their metadata (offsets).

Source

pub fn decode<T: DeserializeOwned>(&self) -> Result<T>

Standard single-threaded deserialization. Use this for leaf nodes or simple structs that fit in memory.

Source

pub fn decode_parallel_collection<T>(&self) -> Result<Vec<T>>
where T: ParcodeItem,

Parallel Shard Reconstruction

Reconstructs a Vec<T> by deserializing shards concurrently.

§Safety

This function uses unsafe to write directly into an uninitialized buffer. To ensure safety:

  1. We pre-calculate correct offsets using RLE metadata.
  2. We cast the buffer pointer to usize to safely pass it to Rayon threads.
  3. We verify that the number of items read from a shard matches the RLE expectation (expected_count). If not, we abort before writing, preventing partial initialization UB.
Source

pub fn len(&self) -> u64

Returns the logical number of items in this container.

Source

pub fn is_empty(&self) -> bool

Checks if the container is empty.

Source

pub fn get<T: ParcodeItem>(&self, index: usize) -> Result<T>

Retrieves item at index using RLE arithmetic.

This calculates which shard holds the item, loads ONLY that shard, and returns the specific item.

Source

pub fn iter<T: ParcodeItem>(self) -> Result<ChunkIterator<'a, T>>

Creates a streaming iterator over the collection. Memory usage is constant (size of one shard) regardless of total size.

Source

pub fn get_child_by_index(&self, index: usize) -> Result<Self>

Retrieves a child ChunkNode by its index in the footer.

Source

pub fn offset(&self) -> u64

Returns the absolute file offset of this chunk.

Source

pub fn length(&self) -> u64

Returns the total physical length of this chunk.

Source

pub fn child_count(&self) -> u32

Returns the number of children.

Source

pub fn meta(&self) -> MetaByte

Returns the metadata flags.

Source

pub fn payload_len(&self) -> u64

Calculates the size of the payload (excluding metadata/footer).

Trait Implementations§

Source§

impl<'a> Clone for ChunkNode<'a>

Source§

fn clone(&self) -> ChunkNode<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for ChunkNode<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ChunkNode<'a>

§

impl<'a> !RefUnwindSafe for ChunkNode<'a>

§

impl<'a> Send for ChunkNode<'a>

§

impl<'a> Sync for ChunkNode<'a>

§

impl<'a> Unpin for ChunkNode<'a>

§

impl<'a> !UnwindSafe for ChunkNode<'a>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V