repe-rs¶
Rust implementation of the REPE RPC protocol with JSON and BEVE body support.
What's in the box¶
- REPE header and message types with correct little-endian wire encoding.
- Streaming and zero-copy I/O (
MessageView,write_message_streaming) for large bodies. - JSON and BEVE bodies via
structio: one declaration serves both formats, with no document model, no derive, and no proc macro in the dependency graph. - A bulk fast path for high-throughput numeric bodies (typed numeric and complex arrays) that encodes, decodes, and frames a whole-body slice in a single copy.
- Sync and async (tokio) clients and servers, with multiplexed in-flight requests, per-call timeouts, batching, and notify support.
- Dynamic
Registryrouting with JSON Pointer semantics. FleetAPIs for multi-node TCP and UDP fanout.- Optional REST gateway (
RestGateway) fronting aRegistryover HTTP/1.1 and HTTP/2, with verb-checked reads/writes/calls,ETagrevalidation, and JSON/BEVE negotiation. - Optional WebSocket transport, including a wasm browser client and server-pushed notify subscriptions.
- Optional
streammodule for backpressure-controlled bulk transfers with reconnect-resume. - Optional
repeCLI for talking to any REPE server over TCP or WebSocket. - Wire compatibility with the canonical C++ implementation (Glaze), pinned by an automated interop fixture suite.
Install¶
Or cargo add repe. The CLI ships under a feature flag: cargo install repe --features cli.
Quick start¶
use repe::{BodyFormat, Message, QueryFormat};
let msg = Message::builder()
.id(42)
.query_str("/status")
.query_format(QueryFormat::JsonPointer)
.body_json(&Ping { ping: true })
.build();
let bytes = msg.to_vec();
let parsed = repe::Message::from_slice(&bytes)?;
assert_eq!(parsed.header.id, 42);
assert_eq!(parsed.header.body_format, BodyFormat::Json as u16);
assert!(parsed.json_body::<Ping>()?.ping);
# Ok::<(), Box<dyn std::error::Error>>(())
Replace body_json with body_beve to encode the body with BEVE; everything else is identical.
Where to next¶
- New here? Start with the wire format for a quick mental model, then read the server and client pages.
- Building dynamic routes? See Registry.
- Multi-node deployments? See Fleet.
- Exposing a registry to public clients or a CDN? See REST gateway.
- Pushing through firewalls or browsers? See WebSocket.
- Moving large payloads with flow control? See Streaming.
- Debugging from a terminal? See the CLI.
- Interoperating with C++ (Glaze) or another REPE implementation? See Interoperability.
Feature flags¶
| Flag | Effect |
|---|---|
rest |
RestGateway: a REST facade over a Registry, served on HTTP/1.1 and HTTP/2. |
websocket |
Native WebSocketClient, WebSocketServer, and proxy_connection. |
websocket-wasm |
Browser WasmClient on wasm32-unknown-unknown. |
fleet-udp |
UDP fanout via UniUdpFleet. |
value-stream |
Streaming value transfer (SVS), with an optional Zstandard codec (pure Rust, no C toolchain). |
parking-lot |
Lockable impls for parking_lot::Mutex / RwLock. |
cli |
Builds the repe command-line client (pulls in clap and websocket). |
fleet-udp, value-stream, and rest are native-only: on wasm32-unknown-unknown their modules and their non-portable dependencies both compile away, so enabling any of them there is inert rather than a build failure. That matters for a workspace hoisting one shared feature set across a native server and a browser client, since Cargo features are additive and the wasm member cannot subtract one.
License¶
MIT, see LICENSE in the repo.