Exchange Example

Multi-schema exchange-shaped sample. with_conversion only for Decimal — no with_domain_type. publish = false.

Conversion style

#![allow(unused)]
fn main() {
    use ergo_sbe::{ConversionSelector, GenerationConfig};
    // A — generic converter: one wire type, many app types
    let _cfg =
        GenerationConfig::new("msgs").with_conversion(ConversionSelector::named_type("Decimal"));
}

(From book/examples/conversion-config.rs. Full multi-schema build.rs: exchange-example.)

That emits generic methods. The app supplies TryFromSbe / TryToSbe:

// encode: app Decimal → wire
e.price_from(&d)?;

// decode: wire → app Decimal
let d: rust_decimal::Decimal = level.price_as()?;

You still have wire accessors (price_value / price_wire). You do not get a concrete price() -> rust_decimal::Decimal — that requires with_domain_type(..., "rust_decimal::Decimal") (see L3 Order Book).

SampleConfig
This cratewith_conversion only
L3 Order Bookwith_domain_type only
SBE Feature Tourboth (demo_conversion_only is conversion-only)

Run

cargo test --manifest-path samples/exchange-example/Cargo.toml