parcode-derive

Crates.ioparcode-derive
lib.rsparcode-derive
version0.4.0
created_at2025-12-10 06:59:39.214019+00
updated_at2025-12-17 16:52:27.882116+00
descriptionProcedural macros for the Parcode high-performance serialization library.
homepage
repositoryhttps://github.com/retypeos/parcode
max_upload_size
id1977616
size33,276
Rety (Retype15)

documentation

README

Parcode Derive

Crates.io License

This crate provides the #[derive(ParcodeObject)] procedural macro for the Parcode library.

Note: You likely do not need to add this crate directly to your Cargo.toml. Instead, use the parcode crate which re-exports this macro.

Usage

Deriving ParcodeObject on a struct automatically implements:

  1. Serialization Logic: Optimized, parallel-ready serialization.
  2. Lazy Mirroring: Generates a shadow struct (e.g., MyStructLazy) for zero-copy field access.
use parcode::ParcodeObject;
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, ParcodeObject)]
struct Level {
    // Local fields (stored in the main payload)
    id: u32,
    name: String,

    // Chunkable fields (stored in separate shards for parallel access)
    #[parcode(chunkable)]
    geometry: Vec<u8>,

    // Optimized Map (O(1) random access via hashing)
    #[parcode(map)]
    users: std::collections::HashMap<u64, String>,
    
    // Custom compression per field
    #[parcode(chunkable, compression = "lz4")]
    assets: Vec<u8>,
}

Attributes

  • #[parcode(chunkable)]: Marks a field (usually a Vec or nested Struct) to be stored in its own graph node. This enables lazy loading and parallel writing for this field.
  • #[parcode(map)]: Activates "Hash Sharding" for HashMap types. This splits the map into buckets and builds micro-indexes, allowing $O(1)$ lookup without deserializing the whole map.
  • #[parcode(compression = "...")]: Overrides the compression algorithm for this specific field. Supported values: "none", "lz4".

License

This project is licensed under the MIT license.

Commit count: 0

cargo fmt