Skip to main content

ruststream_nats/
lib.rs

1//! `NATS` / `JetStream` broker implementation for `RustStream`.
2//!
3//! The lifecycle is the framework's ladder of consuming transitions: [`NatsBroker::new`] captures
4//! the address synchronously, [`Broker::connect`](ruststream::Broker::connect) dials and yields a
5//! [`ConnectedNatsBroker`], and
6//! [`ConnectedBroker::shutdown`](ruststream::ConnectedBroker::shutdown) drains it into a
7//! [`ClosedNatsBroker`]. Subscriptions and publishers exist only from the connected form.
8//!
9//! Publishing splits by transport rather than by flag: [`NatsPublish`] pairs into the Core NATS
10//! [`NatsPublisher`] (fire-and-forget, plus request/reply), and [`JetStreamPublish`] pairs into
11//! the [`JetStreamPublisher`], which awaits the stream's acknowledgement and can state what it
12//! expects the stream to look like.
13
14#![forbid(unsafe_code)]
15
16mod broker;
17mod convert;
18mod error;
19mod jetstream;
20mod message;
21mod publisher;
22mod request_reply;
23mod subscribe_options;
24mod subscriber;
25
26pub mod context;
27
28pub use broker::{ClosedNatsBroker, ConnectedNatsBroker, NatsBroker};
29pub use error::NatsError;
30pub use jetstream::{JetStreamPublish, JetStreamPublisher, PublishAck};
31pub use message::{CoreMessage, JetStreamMessage, NatsMessage, PARTITION_KEY_HEADER};
32pub use publisher::{NatsPublish, NatsPublishPolicy, NatsPublisher};
33pub use subscribe_options::{DeliverPolicy, SubscribeOptions};
34pub use subscriber::NatsSubscriber;
35
36#[cfg(feature = "testing")]
37pub mod testing;