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.
- Pluggable codecs: JSON, MessagePack, and CBOR behind cargo features, or raw bytes with none.
- Zero-boilerplate binaries.
#[subscriber]and#[ruststream::app]macros, and a CLI that scaffolds, runs and documents a service. - 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.
- Capability traits for batches, transactions, request-reply, partitioning and repositioning; a broker implements only what it supports.
Install
[]
= { = "0.7", = ["macros", "memory", "json"] }
= { = "1", = ["derive"] }
The CLI ships with the crate behind the cli feature:
Write a service
use *;
use Deserialize;
async
#[ruststream::app] generates main, so there is no runtime boilerplate.
Run it
Scaffold a fresh project with cargo generate --git https://github.com/powersemmi/ruststream templates/memory --name my-service (each broker crate ships its own template). See the
quick start.
Test it
TestApp runs the service's own app in process, with no external broker.
use TestApp;
let tb = start.await?;
// Inject an order; the harness drives the handler to completion before returning.
tb.
.message
.to
.publish
.await?;
// The handler ran once, decoded the order, and acked.
tb.
.subscriber
.assert_called_once
.with
.settled;
Full compiling example: examples/testing.rs.
Brokers
| Broker | Crate |
|---|---|
| NATS | ruststream-nats |
| Redis / Valkey | ruststream-fred |
| RabbitMQ (AMQP 0.9.1) | ruststream-lapin |
| Apache Kafka | ruststream-rdkafka |
| AMQP 1.0 | ruststream-amqp |
| Google Cloud Pub/Sub | ruststream-gcp-pubsub |
| Amazon SQS / SNS | ruststream-sqs-sns |
| Apache Pulsar | ruststream-pulsar |
| MQTT 5 | ruststream-rumqttc |
| ZeroMQ | ruststream-zeromq |
| Files and stdio | ruststream-sea-file |
| Amazon Kinesis | ruststream-kinesis |
| SQL databases (Postgres, MySQL / MariaDB, SQLite) | ruststream-sqlx |
What each broker supports is on the broker index. To write a broker, see the broker-authors guide.
Documentation
- Site: https://powersemmi.github.io/ruststream/latest
- API reference and topic overviews: https://docs.rs/ruststream
Minimum supported Rust version
The MSRV is 1.95, edition 2024. The policy is a rolling one, as in tower: the MSRV rises only to a Rust release at least six months old, and only in a minor release. A broker crate may require a newer toolchain when its client does.
Contributing
See CONTRIBUTING.md.
License
Licensed under the Apache-2.0 license.
Inspired by FastStream.