iridium_stomp/lib.rs
1#![doc = include_str!("../README.md")]
2
3//! Additional user-facing guides from the `docs/` directory are exposed as
4//! rustdoc modules so they appear on docs.rs. See the `subscriptions_docs`
5//! module for information about durable subscriptions and `SubscriptionOptions`.
6pub mod codec;
7pub mod connection;
8pub mod frame;
9pub mod parser;
10pub mod subscription;
11
12/// Re-export the codec types (`StompCodec`, `StompItem`) for easy use with
13/// `tokio_util::codec::Framed` and tests.
14pub use codec::{StompCodec, StompItem};
15
16/// Re-export the high-level `Connection`, `AckMode`, `ConnectOptions`, `ConnError`,
17/// `Heartbeat`, `ReceivedFrame`, `ServerError`, and the heartbeat helper functions.
18pub use connection::{
19 AckMode, ConnError, ConnectOptions, Connection, Heartbeat, ReceivedFrame, ServerError,
20 negotiate_heartbeats, parse_heartbeat_header,
21};
22
23/// Re-export the `Frame` type used to construct/send and receive frames.
24pub use frame::Frame;
25pub use subscription::Subscription;
26pub use subscription::SubscriptionOptions;
27
28// Expose the repository `docs/subscriptions.md` as a public rustdoc page so it
29// appears alongside the API docs on docs.rs / rustdoc. The module is empty and
30// only serves to carry the included markdown.
31#[doc = include_str!("../docs/subscriptions.md")]
32pub mod subscriptions_docs {}
33
34#[cfg(test)]
35mod tests {
36 use super::*;
37
38 #[test]
39 fn smoke_frame_display() {
40 let f = Frame::new("CONNECT")
41 .header("accept-version", "1.2")
42 .set_body(b"hello".to_vec());
43 let s = format!("{}", f);
44 assert!(s.contains("CONNECT"));
45 assert!(s.contains("Body (5 bytes)"));
46 }
47}