zon-lib 0.1.0

6.2x faster than JSON. A zero-copy, memory-mapped data format for high-performance systems.
Documentation
  • Coverage
  • 22.73%
    5 out of 22 items documented0 out of 14 items with examples
  • Size
  • Source code size: 37.26 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • zaim-abbasi

ZON

The Zero-Overhead Notation for High-Performance Systems.

Build License Speed

The Problem

Data serialization implies a cost. Formats like JSON force CPUs to burn cycles parsing text, allocating strings, and managing garbage, turning every data access into a computation. For high-frequency systems, this latency is unacceptable.

ZON changes the paradigm. It maps files directly to memory. By using pointer-less relative offsets and strict 64-byte alignment, the on-disk format is the in-memory representation. It is cache-line friendly, mmap-ready, and requires zero parsing.

JSON (Traditional):
[Disk] -> [Read String] -> [Parse Text] -> [Allocate Object] -> [Memory] 🐢

ZON (Zero-Overhead):
[Disk] ------------------ (mmap) -------------------------> [Memory] 🚀

The Evidence

Benchmarks comparing ZON against standard JSON deserialization for a composite game entity (Player struct):

Format Mean Access Time Throughput Speedup
JSON ~117.43 ns ~8.5 M ops/s 1x
ZON ~18.83 ns ~53.1 M ops/s 6.2x

> Benchmark conducted on a strictly aligned composite workload.

Quick Start

Usage

use zon_format::{ZonWriter, ZonReader};

fn main() {
    // 1. Write Data
    let mut writer = ZonWriter::new();
    
    // Write a string (returns offset to length prefix)
    let name_offset = writer.write_string("Hero");
    
    // Write an integer
    let score_offset = writer.write_u32(9001);
    
    // Link the root of the file to the name
    writer.set_root(name_offset);
    
    // 2. Read Data (Zero-Copy)
    let buffer = writer.as_bytes();
    let reader = ZonReader::new(buffer).expect("Valid ZON file");
    
    // Read the root pointer (stored at offset 8 in header)
    let root_ptr = reader.read_u32(8).unwrap();
    
    // Resolve the string directly from the buffer without allocation
    let name = reader.read_string(root_ptr).unwrap();
    
    assert_eq!(name, "Hero");
}

Philosophy

Data should not be parsed. It should be read.

ZON is built for systems where latency is the primary constraint:

  • High-Frequency Trading (HFT)
  • Game Engines (Entity Component Systems)
  • Large Scale Distributed Systems

By eliminating the transformation layer between disk and memory, we free the CPU to do actual work.

Installation

Add to your Cargo.toml:

[dependencies]

zon-format = "0.1.0"