nexus-standard 1.0.0

Zero-copy compiler and reader for the Nexus Standard (NXS) bi-modal serialization format
Documentation

NXS — Rust

The reference compiler (.nxs.nxb) and core library. Also provides a direct binary writer for generating .nxb without a source text round-trip.

Requirements

Rust 1.75+ (stable).

Build

cd rust
cargo build --release

Compile .nxs to .nxb

./target/release/nxs data.nxs           # writes data.nxb
./target/release/nxs data.nxs out.nxb   # explicit output path

Write .nxb directly

For bulk generation — no source text round-trip:

use nxs::writer::{NxsWriter, Schema, Slot};

let schema = Schema::new(&["id", "username", "score", "active"]);
let mut w = NxsWriter::with_capacity(&schema, records.len() * 128 + 256);
for r in &records {
    w.begin_object();
    w.write_i64(Slot(0), r.id);
    w.write_str(Slot(1), &r.username);
    w.write_f64(Slot(2), r.score);
    w.write_bool(Slot(3), r.active);
    w.end_object();
}
let bytes: Vec<u8> = w.finish();

Tests

cargo test
cargo test test_compile_basic   # single test by name

Benchmarks

cargo run --release --bin bench

Generate fixtures

All language benchmarks share a fixture directory. Generate before running cross-language benchmarks:

cargo run --release --bin gen_fixtures -- ../js/fixtures 1000000
# writes records_1000000.{nxb,json,csv}

Source layout

File Purpose
src/main.rs nxs binary — CLI entry point
src/lexer.rs Tokenizes .nxs source (sigils, keys, braces, brackets)
src/parser.rs Builds an AST of Field { key, value } nodes
src/compiler.rs Two-pass compiler: key dictionary, then binary emission
src/writer.rs NxsWriter / Schema / Slot — direct binary writer API
src/decoder.rs Minimal decoder used by tests
src/error.rs NxsError enum
src/bench.rs bench binary
src/gen_fixtures.rs gen_fixtures binary

For the format specification see SPEC.md. For cross-language examples see GETTING_STARTED.md.