Skip to main content

Installation

A service depends on one crate, ruststream, whose surface is enabled by additive cargo features. It re-exports the crates RustStream is built from, so a service never names them. Add it to your Cargo.toml:

[dependencies]
ruststream = { version = "0.8", features = ["macros", "memory", "json"] }
serde = { version = "1", features = ["derive"] }

serde is a direct dependency of your service because your message types derive Deserialize / Serialize.

Edition and MSRV

RustStream targets edition 2024 and a minimum supported Rust version of 1.95. Set edition = "2024" in your Cargo.toml. A broker crate may need a newer Rust than the core when its client library does. The broker crate's own rust-version field states the exact minimum version.

Features​

The core traits, the Router, middleware and message dispatch are always compiled. The application object comes with a runner feature, and everything else is an additive feature you enable when you need it.

FeaturePulls inWhat it gives you
tokio (default)tokiothe tokio runner: RustStream, the application object that runs on tokio
compiocompiothe compio runner, one runtime per core, on io_uring where the kernel has it
embassyembassythe embassy runner for firmware: EmbeddedApp
tracing, log, defmtthe logging crate of the same namethe loggers an app selects with .logger(..); the tokio runner turns tracing on
json (default)serde_jsonJsonCodec
msgpackrmp-serdeMsgpackCodec
cborciboriumCborCodec
memory-MemoryBroker, the in-memory reference broker
macrosruststream-macros#[subscriber], #[ruststream::app], and the derives (Outgoing, OutSlot, OutMessages, Deserialized, Serialized, FromRef, MessageInfo)
asyncapischemars, serde_norwayAsyncAPI generation and the HTML viewer
metricsprometheusPrometheus middleware and exporter
loggingtracing-subscriberruststream::logging, a colored console logger (Logging)
otelopentelemetry, opentelemetry-otlpOTLP export for traces and metrics, and W3C trace-context propagation (OpenTelemetry)
testinginventoryTestApp and the assertion builders (Testing)
conformanceinventorythe broker-author conformance harness
cliclap, anyhowthe ruststream binary

You can enable several codecs at once (see Codecs). To drop the bundled JSON codec (for example in a broker crate that needs only the traits and the runtime), disable the default features and name the runtime:

[dependencies]
ruststream = { version = "0.8", default-features = false, features = ["tokio"] }

Without the standard library​

A broker crate for a device depends on the facade too. With the default features off, ruststream builds with #![no_std] and keeps headers and payloads in storage of a fixed size:

[dependencies]
ruststream = { version = "0.8", default-features = false }

With the alloc feature it keeps them on the heap:

[dependencies]
ruststream = { version = "0.8", default-features = false, features = ["alloc"] }

The standard library comes with the runtimes that need it, tokio and compio. They and the codecs that need a heap turn alloc on themselves.

The CLI​

The ruststream binary ships with the crate behind the cli cargo feature. It runs cargo with the framework's subcommands (run, asyncapi gen); installation and commands are in the runtime::cli module. cargo generate scaffolds a new project from a template, covered in the quick start.

Concrete brokers​

The memory broker is built into the crate and needs no external service. To reach a broker outside the process, depend on that broker's crate; it re-exports from ruststream everything it needs.

Each broker has its own version and its own release cycle, so the exact dependency line, with the current version and the testing feature for handler tests, is in the broker's own documentation. The same documentation describes the broker's connection options and its capabilities.

The available brokers are listed under Brokers; the link there leads to each broker's documentation and its installation instructions. To write your own broker, see the Broker trait.