Rust Client

The simulator-client and simulator-api crates provide a native Rust interface to the Termina simulator, for teams who want to integrate backtesting directly into their Rust code rather than using the sim CLI.

  • simulator-client is the high-level async client. It wraps the WebSocket protocol with ergonomic builders for common workflows: creating sessions, advancing slots, injecting transactions, and reading account state.

  • simulator-api defines the raw protocol types (request/response structs, error variants, session parameters). Use it if you need direct access to the wire format or want to implement your own client.

Installation

[dependencies]
simulator-client = "0.7"
simulator-api = "0.7" # If you only need the protocol types (e.g. to build a custom client):

Examples

Available Slots

Before creating a session, confirm the slot range you want to replay is available:

let ranges = client.available_ranges().await?;
for r in &ranges {
    println!(
        "slots {}{}",
        r.bundle_start_slot,
        r.max_bundle_end_slot.unwrap_or(0)
    );
}

Program Overrides

Load a compiled ELF binary and patch it into the session.

Reads + Writes

Use the session's RPC client to send transactions and read accounts.

Subscriptions

Session Summaries

Enable send_summary at session creation to receive transaction-level statistics on completion. The Completed response will include a SessionSummary with counts of correct simulations, mismatches, balance diffs, and execution errors.

Last updated