caelum0x 8215fb82de feat(ration): add sdk/rust/ration-client, a typed Rust client for gateway.proto
Phase 2 section 7 (docs/SCALE-EXPANSION.md): the Rust counterpart to
sdk/go/ration — client-only tonic stubs for gateway.proto/common.proto
(build.rs also generates server stubs, same as ledger-core's build.rs does
for audit.proto, so this crate's own tests can stand up a fake Gateway
server with no network).

Verified: cargo build, cargo clippy --all-targets -- -D warnings (clean),
cargo fmt --check, cargo test (7 unit tests against an in-process duplex-pipe
gateway server + 1 doc-test), all passing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-19 12:54:25 +03:00

1.5 KiB

ration-client

A typed Rust client for Ration's gateway.proto Gateway service — the Rust counterpart to sdk/go/ration.

let mut client = ration_client::Client::connect("http://localhost:7002").await?;

let card = client
    .issue_card("tenant_1", "Jane Doe", 1_000_00, "monthly", "USD")
    .await?;
println!("issued {}", card.id);

let result = client
    .request_bridge_funding("tenant_1", 500_00, "card settlement due")
    .await?;
println!(
    "granted {} of 50000 requested: {}",
    result.granted_minor_units, result.explanation
);

use tokio_stream::StreamExt;
let mut events = client.stream_activity("tenant_1").await?;
while let Some(event) = events.next().await {
    let event = event?;
    println!("{} {}", event.kind, event.summary);
}

Client::connect dials in plaintext by default. For mTLS against a production deployment (see pkg/mtls, infra/dev-ca/), build your own tonic::transport::Channel with ClientTlsConfig and construct via Client::from_channel.

Card and ActivityEvent are re-exported directly from the generated protobuf types — this crate adds ergonomic, typed method signatures on top of the tonic-generated client, it does not reinvent the wire format.

REST is also available as a convenience facade over this same gRPC service — see ../../../services/gateway/internal/httpapi — for callers who'd rather curl than link a gRPC client.