Skip to main content

Module prelude

Module prelude 

Source
Expand description

The imports a routes file on the PUSH/PULL queue writes, in one glob: the framework’s prelude, the shared ZmqEndpoint, the broker ZmqQueue, and its publish policy as Publish.

§Examples

use ruststream_zeromq::queue::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Deserialize)]
struct Job {
    id: u64,
}

// The result queue belongs to the message, so the type names it and the clause stays bare.
#[derive(Serialize, Outgoing)]
#[outgoing(name = "results")]
struct Done {
    id: u64,
}

#[subscriber("jobs", reply)]
async fn handle(job: &Job) -> Done {
    Done { id: job.id }
}

#[ruststream::app]
fn app() -> impl App {
    // The results travel on a queue of their own: the one the jobs arrive on would hand a
    // result back to `handle` as its next job.
    let results = ZmqQueue::new(ZmqEndpoint::connect("tcp://sink:5556")).bindable();
    let to_results = results.bind(Publish);
    RustStream::new(AppInfo::new("worker", "0.1.0"))
        .with_broker(ZmqQueue::new(ZmqEndpoint::bind("tcp://0.0.0.0:5555")), |b| {
            b.include(handle).out_reply(to_results);
        })
        .with_broker(results, |_b| {})
}

Re-exports§

pub use super::Publish;
pub use super::ZmqQueue;

Macros§

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

Structs§

AppInfo
Service-level metadata, surfaced to the AsyncAPI generator as the spec Info object.
BytesMut
The buffer the crate’s byte-producing surfaces speak: what a Codec returns, what a Serialized value writes into, and the payload a publisher that declared Take is handed.
CallerName
The destination form of a type declaring no name: the call site names the destination.
Context
Per-delivery context, threaded through middleware and into the handler.
Ctx
Extractor that injects one broker context field into a handler, by its key.
DefaultSlot
The implicit marker of a single unnamed Out<impl Publisher> parameter.
FailurePolicies
The pair of failure policies a subscriber carries: one for a handler panic, one for a decode failure. Threaded from the def to the dispatch loop alongside the Workers policy.
FixedName
The destination form of a type declaring one literal name: the name is fixed, so the publish builder resolves the destination without asking the call site.
ForReply
The kind of a reply position: the transform reads the delivery it answers, as a PublishContext over the handler’s own context type C.
ForSlot
The kind of an Out slot position: the transform reads a SlotContext, which names the slot and nothing else.
HandlerOutcome
The settlement of one dispatched message: the broker status the dispatcher acts on, plus an optional post-settle continuation.
HeaderMap
Case-insensitive map of broker-message headers.
Headers
Extractor that parses the delivery headers into a typed contract before the body runs.
MainRuntime
The runtime the app runs on, as a handler reaches it: Ctx(main): Ctx<MainRuntime> as a parameter, or Context::main_runtime.
Message
One incoming message together with its decoded typed header contract.
Name
The default SubscriptionSource: subscribe by name string via the Subscribe capability.
NameTemplate
The destination form of a type declaring a name template: the call site binds every placeholder through the setters generated from it, and the name is rendered per publish.
Names
The transform names the destination. A position offers this only where the destination is not already declared, so a declaration and the wire cannot disagree.
NoHeaders
The header contract of a message that carries no typed headers.
Out
The marker a handler signature uses to receive an injected publisher: Out(out): Out<impl Publisher> binds out to a live publisher inside the body.
OutgoingMessageMetadata
One message a handler publishes, as declared for the AsyncAPI document.
Outs
The injections arena a slot body receives: its entries mirror the marker tuple the body declared, and get picks one by marker.
Reads
The transform reads the destination and leaves it alone. What almost every transform declares, and what every position offers.
Reply
The marker of a handler’s reply position: .out(Reply, policy) names the publish policy the value a reply("dest") handler returns leaves through.
Retry
The marker of a registration’s deferred-retry slot: .out(Retry, policy) names the publish policy a retry_after copy leaves through.
Router
A statically-typed, lazily-bound group of handler registrations, not attached to any broker.
RunningApp
A started service, handed out by RustStream::start.
RustStream
The top-level application object.
SerializedReply
The serialized reply wire: the value already carries its bytes (Serialized replies), and they leave as they are, with no codec.
SerializedWire
The serialized wire of a typed publish: the value already carries its bytes (Serialized), and they leave as they are, with no codec.
Slot
One arena entry: the wired live value of the marker M, plus the publish path the include site gave it - its encode codec and the pipeline every message leaving the slot travels.
SoloDeserialized
The single self-deserializing input: In = F<'_> for a Deserialized F.
State
Extractor that injects a piece of the shared application state into a handler.
Unnamed
The stand-in a definition carries while its subscription has no name yet.
WithHeaders
The header contract of a message whose headers are the typed struct H.
Workers
Concurrency policy for one subscriber’s dispatch loop, declared with the workers(..) or threads(..) macro argument (or Workers::sequential by default).
ZmqEndpoint
An address (tcp://... or ipc://...) and the side of it this process takes, fixed by the constructor and carried in the type.

Enums§

FailurePolicy
What a subscriber does when it cannot process a message.
WireBytes
Where a Serialized value’s bytes are: in the buffer it was handed, or in the value itself.

Traits§

App
The functional surface of a built RustStream service: run it, and read the metadata the AsyncAPI generator and the generated CLI need.
Broker
An unconnected broker: configuration captured, no I/O performed yet.
ContextKind
What one publish position hands its transforms.
Deserialized
A type that deserializes itself from the payload bytes: Deserialize means the framework’s codec does it, Deserialized means it is already done by the user’s own type.
FromContext
A value resolved from the per-delivery Context and shared state, ready to be passed to a handler as a parameter.
FromRef
Produces a value from a reference to the shared application state S.
Handle
The one body contract of the manual path: every axis of the form matrix is a defaulted parameter the impl pins.
IncomingMessage
A message delivered by a Subscriber.
Input
A Handle input spelling: a decoded T, a Deserialized type, a Message<H, P> pair, a value the delivery already holds (Carries), or a batch (slice) of any of them.
MapPublisher
Replaces the publish policy of the position a mount chain named last, keeping every step the chain already filled: the hook a broker crate layers its own publisher settings on.
MessageHeaders
Declares a message type’s typed header contract.
MessageInfo
Metadata about a message type, used to name and describe it in an AsyncAPI document.
MessageWire
The wire of a typed publish value: whether the resolved codec serializes it.
OutEntry
What one arena entry is, stated as the mount’s choices rather than spelled out: the bound marker M, and the wired value, codec and publish path the include site gave it.
OutMessages
A declared message set’s AsyncAPI contribution: one OutgoingMessageMetadata entry per member, each read off the member’s own declaration.
OutSlot
A slot marker: the identity of one Out injection.
OutgoingDestination
Declares where a message type is sent.
OwnedTransactions
A publisher that opens caller-owned, client-buffered transactions.
PublishExt
The publish builder on any Publisher: message(..), the one entry point of a publish.
PublishPolicy
The declaration half of a publisher: pure policy, no connection, no publish surface.
PublishTransform
A static, compile-time publish transform: mutates an Outgoing before it is sent, with read access to whatever its position hands it.
PublishedThrough
Membership of a message type in a slot marker’s #[publishes(..)] dictionary: the type may leave through a slot identified by Slot.
Publisher
A producer that sends messages into the broker.
ReplyShape
The shape and wire of a reply value: what payload it publishes, what typed header contract rides it, and whether the framework’s codec serializes it.
RequestReply
A publisher that supports synchronous request / reply messaging.
RouterDef
A mountable group of handler registrations.
Serialized
A value that owns its byte layout: Serialize means the framework’s codec does the work, Serialized means the type produces the bytes itself.
SubscriberSettings
The declarative settings, chainable on a #[subscriber] definition and on the builder alike.
TransactionalPublisher
A publisher that supports broker-side transactions.

Functions§

subscriber
Binds a Handle body to its subscription source; the one mounting verb of the manual path.

Type Aliases§

Str
The owned string of the message path: a destination name, a header key.