pub trait ParcodeNative: Sized {
// Required method
fn from_node(node: &ChunkNode<'_>) -> Result<Self>;
}Expand description
A trait for types that know how to reconstruct themselves from a ChunkNode.
This trait enables the high-level API (Parcode::load) to
automatically select the optimal reconstruction strategy based on the type being read.
§Strategy Selection
Different types use different reconstruction strategies:
Vec<T>: Parallel reconstruction across shards (seeChunkNode::decode_parallel_collection)HashMap<K, V>: Shard merging with SOA deserialization- Primitives: Direct bincode deserialization
- Custom Structs: Sequential deserialization of local fields + recursive child loading
§Automatic Implementation
This trait is automatically implemented by the #[derive(ParcodeObject)] macro for custom
structs. Primitive types and standard collections have manual implementations in this module.
§Example
use parcode::Parcode;
// Automatically selects parallel reconstruction for Vec
let data = vec![1, 2, 3];
Parcode::save("numbers_native.par", &data).unwrap();
let data: Vec<i32> = Parcode::load("numbers_native.par").unwrap();
// Automatically selects sequential deserialization for primitives
let val = 42;
Parcode::save("value_native.par", &val).unwrap();
let value: i32 = Parcode::load("value_native.par").unwrap();Required Methods§
Sourcefn from_node(node: &ChunkNode<'_>) -> Result<Self>
fn from_node(node: &ChunkNode<'_>) -> Result<Self>
Reconstructs the object from the given graph node.
This method is called by Parcode::load after opening the
file and locating the root chunk. Implementations should choose the most efficient
reconstruction strategy for their type.
§Parameters
node: The chunk node to reconstruct from (typically the root node)
§Returns
The fully reconstructed object of type Self.
§Errors
Returns an error if:
- Decompression fails
- Deserialization fails (type mismatch, corrupted data)
- Child nodes are missing or invalid
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<K, V> ParcodeNative for HashMap<K, V>
impl<K, V> ParcodeNative for HashMap<K, V>
Source§impl<T> ParcodeNative for Vec<T>where
T: ParcodeItem,
Uses Parallel Stitching.
impl<T> ParcodeNative for Vec<T>where
T: ParcodeItem,
Uses Parallel Stitching.