Skip to main content

Crate ruststream

Crate ruststream 

Source
Expand description

Rust core of the RustStream messaging framework: broker-agnostic traits, message types, codecs, router runtime, and a conformance harness for broker authors.

§Cargo features

The core traits, the runtime::RustStream application object, middleware, and dispatch are always present. The rest is additive and opt-in. Codec features are mutually compatible and enable only the deserializers you need.

  • json (default): codec::JsonCodec.
  • msgpack: [codec::MsgpackCodec].
  • cbor: [codec::CborCodec].
  • memory: [memory::MemoryBroker], an in-process broker usable in applications, prototypes and tests.
  • macros: the #[subscriber], #[ruststream::app], and #[derive(Message)] macros.
  • asyncapi: AsyncAPI document generation and the HTML viewer.
  • metrics: Prometheus metrics middleware and exporter.
  • logging: colored, RUST_LOG-driven console logging via tracing-subscriber ([logging::init]). The generated cli run command installs it automatically.
  • otel: OpenTelemetry SDK integration: OTLP export for traces and metrics via [otel::OtelBuilder::init], plus per-handler dispatch metrics middleware and W3C trace-context propagation ([otel::propagation]).
  • conformance: the [conformance::harness] contract suite, per-capability suites in [conformance::capabilities], and broker-agnostic [conformance::helpers] for application tests. Generic over any broker’s [testing::TestableBroker], so it pulls in no concrete broker (enable memory too to run it against [memory::MemoryBroker]).
  • testing: the [testing::TestApp] in-process harness for application unit tests.
  • cli: the ruststream binary (run, asyncapi gen, new).

Disable defaults (default-features = false) to drop the bundled JSON codec; the core traits, runtime, and dispatch remain. Add back only what you need.

Re-exports§

pub use runtime::RustStream;

Modules§

codec
Pluggable serialization codecs.
runtime
Application object, middleware and dispatch.
testing
Application unit-testing support, behind the testing feature.

Macros§

nonzero
Builds a NonZero integer from a literal, rejecting zero at compile time.

Structs§

Buffered
A SubscriptionSource adapter that buffers the wrapped source’s subscriber into a BatchSubscriber.
BufferedSubscriber
The subscriber Buffered opens: the wrapped source’s subscriber plus client-side batching.
Headers
Case-insensitive map of broker-message headers.
Name
The default SubscriptionSource: subscribe by name string via the Subscribe capability.
OutgoingMessage
A message ready to be published, holding borrowed payload and name.
PairError
The error of PublishPolicy::pair: whatever the broker reported while bringing a publisher alive, type-erased.
RawMessage
An owned snapshot of a message as it travels through the framework.
SecurityScheme
How clients authenticate to an AsyncAPI server, per the AsyncAPI 3.0 security scheme types.
SeekerPendingError
The subscription behind a SeekerToken has not been opened yet.
SeekerToken
Resolves the Seeker of a subscription mounted through WithSeeker::attach.
ServerSpec
How to reach a broker, for the servers section of an AsyncAPI document.
StartAt
A source decorator opening the subscription at a chosen position instead of the broker’s default.
WithSeeker
A source decorator handing out the subscription’s Seeker through a SeekerToken minted before registration.

Enums§

AckError
Errors returned by IncomingMessage::ack and IncomingMessage::nack.
ApiKeyLocation
Where an apiKey scheme carries the key, per AsyncAPI 3.0.
HttpApiKeyLocation
Where an httpApiKey scheme carries the key, per AsyncAPI 3.0.

Traits§

BatchSubscriber
A subscriber that natively delivers messages in batches.
Broker
An unconnected broker: configuration captured, no I/O performed yet.
BuildContext
Builds a handler’s per-delivery context value from the broker message.
ConnectedBroker
A connected broker: the typed witness of a live connection.
ContextField
A Field-style key that also names its context type and yields an owned value.
DefaultPublish
A connected broker that names its plain publish policy, so the runtime can build a default reply publisher when a publish("dest") handler is included without an explicit one.
DescribeServer
A broker that describes itself as an AsyncAPI server.
Field
A compile-time key reading one typed field out of Src.
FieldMut
A Field key middleware can also write, for per-delivery scratch values.
IncomingMessage
A message delivered by a Subscriber.
Message
Metadata about a message type, used to name and describe it in an AsyncAPI document.
OwnedTransactions
A publisher that opens caller-owned, client-buffered transactions.
Partitioned
Messages or publishers that carry a routing key for broker-side partitioning.
Positioned
A delivered message that knows its own position in the broker’s replayable log.
PublishPolicy
The declaration half of a publisher: pure policy, no connection, no publish surface.
Publisher
A producer that sends messages into the broker.
RequestReply
A publisher that supports synchronous request / reply messaging.
Seekable
A subscriber whose position in a replayable log can be moved.
Seeker
A clonable handle that repositions one subscription, minted by Seekable::seeker.
Subscribe
A connected broker whose subscriptions are fully determined by a name string.
Subscriber
A consumer attached to one or more broker names.
SubscriptionSource
A description of one subscription, resolved against a connected broker at startup.
Transaction
A client-buffered transaction that owns its buffer, opened by OwnedTransactions::transaction.
TransactionalPublisher
A publisher that supports broker-side transactions.

Type Aliases§

Connected
Shorthand for a broker’s connected form, so bounds read S: SubscriptionSource<Connected<B>> instead of spelling the associated type projection.