cratestack-client-rust
Rust HTTP client runtime for CrateStack services.
Overview
cratestack-client-rust provides the typed client runtime that include_client_schema! builds its generated client::Client surface on top of. It owns the HTTP transport, codec negotiation, request authorization hook, and optional offline state journaling.
The CBOR and JSON codecs are re-exported as CborCodec and JsonCodec.
Installation
[]
= "0.2.2"
= { = "1", = ["rt-multi-thread"] }
= "2"
Usage
use include_client_schema;
use ;
include_client_schema!;
let base_url = parse?;
let runtime = new;
let client = new;
Codecs
use ;
let cbor_client = new;
let json_client = new;
Request Authorization
with_request_authorizer attaches an implementation of RequestAuthorizer that returns extra headers per call. The trait gets a canonical-request string the implementer can sign:
use Arc;
use ;
let client = runtime.with_request_authorizer;
State Persistence
Journal requests for replay or offline recovery. The bundled implementations are InMemoryStateStore and JsonFileStateStore; the trait is ClientStateStore.
use Arc;
use ;
let store: = new;
let runtime = runtime.with_state_store;
with_optional_state_store(None) is a no-op convenience for configuration-driven setup.
For a Redis-backed store, see cratestack-client-store-redis. For a SQLite-backed store, see cratestack-client-store-sqlite.
See Also
- Client Runtime
- Transport Architecture
cratestack-codec-cbor— CBOR codeccratestack-codec-json— JSON codeccratestack-client-store-redis— Redis-backedClientStateStorecratestack-client-store-sqlite— SQLite-backedClientStateStore
License
MIT