ergo-sbe 0.1.8

Opinionated, idiomatic Rust code generation for Simple Binary Encoding.
Documentation

ergo-sbe

Crates.io CI API Docs

ergo-sbe generates binary-compatible Rust SBE codecs with compile-time wire-order enforcement, closure-based groups, exact buffer sizing, and zero heap allocation on hot paths.

AI assistance. Large parts of this project were written with heavy AI assistance. Humans directed the work, approved designs, and ran verification. Details: AI-ASSISTANCE.md.

📖 Full Documentation

The Ergon Book is the comprehensive guide for ergo-sbe, covering:

  • Getting Started — depend, generate, encode, decode
  • Feature Tour — exact sizing, bulk arrays, decode stages, DTOs, trust boundaries
  • Core Concepts — wire order, buffer sizing, composites, flyweight vs struct
  • Configurationwith_conversion vs with_domain_type, hooks
  • Recipes — Display/Debug, schema→rustdoc, domain DTOs, timestamps
  • Benchmarks — parity methodology and gates

Quick Example

use ergo_sbe::{parse, Schema, Generator, GenerationConfig};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let xml = r#"<?xml version="1.0"?>
    <messageSchema package="demo" id="1" version="0" byteOrder="littleEndian">
      <types>
        <composite name="messageHeader">
          <type name="blockLength" primitiveType="uint16"/>
          <type name="templateId" primitiveType="uint16"/>
          <type name="schemaId" primitiveType="uint16"/>
          <type name="version" primitiveType="uint16"/>
        </composite>
      </types>
      <message name="Ping" id="1" blockLength="4">
        <field name="seq" id="1" type="uint32" offset="0"/>
      </message>
    </messageSchema>"#;

    let ir = parse(xml)?;
    let schema = Schema::from_ir(ir);
    let modules = Generator::new(GenerationConfig::new("demo_msgs"))
        .generate(&schema)?;
    // In a real project you'd use a build script.
    // Full guide: https://mimran1980.github.io/ergon/sbe/getting-started.html
    let _ = modules;
    Ok(())
}

API Reference

docs.rs/ergo-sbe — generated Rustdoc for the published crate.

License

Apache-2.0.