L3 Order Book
Deep nested / ragged L3 order-book sample for ergo-sbe. publish = false.
Conversion style: with_domain_type only
#![allow(unused)] fn main() { use ergo_sbe::{ConversionSelector, GenerationConfig}; // B — concrete mapping: one Rust type per wire type (already enables conversion) let _cfg = GenerationConfig::new("msgs").with_domain_type( ConversionSelector::named_type("Decimal"), "rust_decimal::Decimal", ); }
(From book/examples/conversion-config.rs. Full L3 build.rs: l3-book.)
Generated API (concrete):
enc.try_price(rust_decimal::Decimal::new(100, 0))?;
let p: rust_decimal::Decimal = dec.try_price()?;
let ts: DateTime<Utc> = dec.try_exchange_timestamp()?;
with_domain_type already enables conversion for that selector. Do not also
call with_conversion(Decimal) here — it would not change the surface.
| Need | Use |
|---|---|
Concrete price() -> Decimal | This sample (with_domain_type) |
Generic price_as::<T>() / app adapters | Exchange Example (with_conversion) |
| Side-by-side both styles | SBE Feature Tour |
Layout
| Path | Role |
|---|---|
schemas/l3-book.xml | Nested bids/asks, orders, var-data tails |
build.rs | generate_to_dir into src/generated/ + domain objects / with_domain_type (build-dep only) |
src/lib.rs | #[path = "generated/l3_codec.rs"] + EncodedLength helpers |
src/main.rs | Runnable demos |
tests/l3_tests.rs | Round-trips |
Run
cargo run --manifest-path samples/l3-book/Cargo.toml
cargo test --manifest-path samples/l3-book/Cargo.toml