iridium-stomp 0.4.0

Async STOMP 1.2 client for Rust
Documentation
#![doc = include_str!("../README.md")]

//! Additional user-facing guides from the `docs/` directory are exposed as
//! rustdoc modules so they appear on docs.rs. See the `subscriptions_docs`
//! module for information about durable subscriptions and `SubscriptionOptions`.
pub mod codec;
pub mod connection;
pub mod frame;
pub mod parser;
pub mod subscription;

/// Re-export the codec types (`StompCodec`, `StompItem`) for easy use with
/// `tokio_util::codec::Framed` and tests.
pub use codec::{StompCodec, StompItem};

/// Re-export the high-level `Connection`, `AckMode`, `ConnectOptions`, `ConnError`,
/// `Heartbeat`, `ReceivedFrame`, `ServerError`, and the heartbeat helper functions.
pub use connection::{
    AckMode, ConnError, ConnectOptions, Connection, Heartbeat, ReceivedFrame, ServerError,
    negotiate_heartbeats, parse_heartbeat_header,
};

/// Re-export the `Frame` type used to construct/send and receive frames.
pub use frame::Frame;
pub use subscription::Subscription;
pub use subscription::SubscriptionOptions;

// Expose the repository `docs/subscriptions.md` as a public rustdoc page so it
// appears alongside the API docs on docs.rs / rustdoc. The module is empty and
// only serves to carry the included markdown.
#[doc = include_str!("../docs/subscriptions.md")]
pub mod subscriptions_docs {}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn smoke_frame_display() {
        let f = Frame::new("CONNECT")
            .header("accept-version", "1.2")
            .set_body(b"hello".to_vec());
        let s = format!("{}", f);
        assert!(s.contains("CONNECT"));
        assert!(s.contains("Body (5 bytes)"));
    }
}