rmqtt_net/
lib.rs

1#![deny(unsafe_code)]
2//! Basic Implementation of MQTT Server
3//!
4//! The basic implementation of MQTT proxy, supporting v3.1.1 and v5.0 protocols, with TLS and
5//! WebSocket functionality.
6//!
7//! ## Basic Usage
8//!
9//! ```rust,no_run
10//! use rmqtt_net::{Builder, ListenerType};
11//! use std::net::SocketAddr;
12//!
13//! #[tokio::main]
14//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
15//!     let builder = Builder::new()
16//!         .name("MyBroker")
17//!         .laddr("127.0.0.1:1883".parse()?);
18//!
19//!     let listener = builder.bind()?;
20//!     loop {
21//!         let acceptor = listener.accept().await?;
22//!         let dispatcher = acceptor.tcp()?;
23//!         // Handle connection...
24//!     }
25//!     Ok(())
26//! }
27//! ```
28
29mod builder;
30mod error;
31mod stream;
32#[cfg(feature = "ws")]
33mod ws;
34
35/// Server configuration and listener management
36pub use builder::{Builder, Listener, ListenerType};
37
38/// Error types for MQTT operations
39pub use error::MqttError;
40
41/// TLS implementation providers
42#[cfg(feature = "tls")]
43pub use rustls;
44
45/// AWS-LC based TLS provider (non-Windows platforms)
46#[cfg(not(target_os = "windows"))]
47#[cfg(feature = "tls")]
48pub use rustls::crypto::aws_lc_rs as tls_provider;
49
50/// Ring-based TLS provider (Windows platforms)
51#[cfg(target_os = "windows")]
52#[cfg(feature = "tls")]
53pub use rustls::crypto::ring as tls_provider;
54
55/// MQTT protocol implementations and stream handling
56pub use stream::{v3, v5, MqttStream};
57
58/// Convenience type alias for generic errors
59pub type Error = anyhow::Error;
60
61/// Result type alias using crate's Error type
62pub type Result<T> = anyhow::Result<T, Error>;