RustStream
English | Русский | 中文
An async messaging framework for Rust: broker-agnostic traits, a router runtime, codecs, AsyncAPI generation, Prometheus and OpenTelemetry observability, and a conformance harness for broker authors.
Documentation
RustStream connects your service to a message broker through a small set of generic traits, then
gives you a router, middleware, codecs, and tooling on top. The core depends on no broker: each
broker is an independent crate held to one contract. The core is 100% safe Rust.
Features
- Broker-agnostic core. Brokers are separate crates, checked by a conformance harness.
- Misuse does not compile. Double acks, out-of-order lifecycle calls and under-specified
publishes are compile errors that name the fix.
- Three runtimes.
tokio (the default), compio with one runtime per core on io_uring where
the kernel has it, and embassy for a device, with or without a heap. The handlers are the same
on each, and the app picks its runner.
- Pluggable codecs: JSON, MessagePack and CBOR behind cargo features, postcard and JSON over
serde-json-core for a device without a heap, or raw bytes with none.
- Zero-boilerplate binaries.
#[subscriber] and #[ruststream::app] macros, and a CLI that
runs a service and prints its AsyncAPI document.
- Observability: AsyncAPI 3.1, Prometheus metrics, a health probe, and OpenTelemetry.
- Tests without a broker. The service's own app runs in process under a test harness.
- Publish errors keep the message. A refused publish hands the unsent message back wherever
the broker's client did not take the payload, so the caller can send it elsewhere.
- Capability traits for batches, transactions, request-reply, partitioning and repositioning;
a broker implements only what it supports.
Install
[dependencies]
ruststream = { version = "0.8", features = ["macros", "memory", "json", "logging"] }
serde = { version = "1", features = ["derive"] }
The CLI ships with the crate behind the cli feature:
cargo install ruststream --features cli
Agent skills
The repository ships skills that teach a coding agent to write RustStream services, their tests
and broker crates the recommended way. In Claude Code:
/plugin marketplace add powersemmi/ruststream
/plugin install ruststream@ruststream
Cursor and Codex read them from
.agents/skills/; the
Agent skills
page lists them.
Write a service
use ruststream::diagnostics::TracingLogger;
use ruststream::memory::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Serialize, Deserialize, Outgoing)]
struct Order {
id: u64,
}