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, so each broker is an independent crate held to one contract; broker-specific configuration never leaks into the framework.
Features
- Broker-agnostic core. Just traits and types, zero broker dependencies. Brokers are separate crates, and the contract is checked by a conformance harness.
- Fully async on tokio. No blocking APIs in the public surface.
- Subscribers are
Streams, not callbacks. Back-pressure comes for free. - Ack consumes
self. Double-ack is a compile error. - Pluggable codecs: JSON, MessagePack, and CBOR behind cargo features.
- Zero-boilerplate binaries.
#[ruststream::app]generatesmain; theruststreamCLI scaffolds projects, runs them, and generates the AsyncAPI document. - AsyncAPI 3.0 and Prometheus metrics, served from your own HTTP stack.
- Colored console logging behind the
loggingfeature; the generated CLI installs it onrun, with verbosity driven byRUST_LOG. - Capability traits for optional features (batch subscribe, transactions, request-reply, partitioning); a broker implements only what it supports.
Install
[]
= { = "0.2", = ["macros", "memory", "json"] }
= { = "1", = ["derive"] }
The CLI ships with the crate behind the cli feature:
Write a service
use JsonCodec;
use MemoryBroker;
use ;
use subscriber;
use Deserialize;
async
#[ruststream::app] generates main, so there is no runtime boilerplate.
Run it
Test it
Unit-test handlers against the in-memory broker, with no external service. It does core routing only, so you assert on handler behaviour, middleware, and decoding exactly as in production. See the testing guide.
Documentation
- Guide and tutorials: https://powersemmi.github.io/ruststream/
- API reference: https://docs.rs/ruststream
- Writing a broker: https://powersemmi.github.io/ruststream/broker-authors/
Ecosystem
ruststream-nats: the NATS broker (Core NATS and JetStream).ruststream-py: Python bindings.
Concrete brokers live in their own crates and pull ruststream from crates.io.
Contributing
License
Licensed under the Apache-2.0 license.
Inspired by FastStream.