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 cert;
31mod error;
32#[cfg(feature = "quic")]
33mod quic;
34mod stream;
35#[cfg(feature = "ws")]
36mod ws;
37
38#[cfg(feature = "quic")]
39pub use quic::QuinnBiStream;
40
41/// Server configuration and listener management
42pub use builder::{Builder, Listener, ListenerType};
43
44pub use cert::{CertInfo, TlsCertExtractor};
45
46/// Error types for MQTT operations
47pub use error::MqttError;
48
49/// TLS implementation providers
50#[cfg(feature = "tls")]
51pub use rustls;
52
53/// AWS-LC based TLS provider (non-Windows platforms)
54#[cfg(not(target_os = "windows"))]
55#[cfg(feature = "tls")]
56pub use rustls::crypto::aws_lc_rs as tls_provider;
57
58/// Ring-based TLS provider (Windows platforms)
59#[cfg(target_os = "windows")]
60#[cfg(feature = "tls")]
61pub use rustls::crypto::ring as tls_provider;
62
63/// MQTT protocol implementations and stream handling
64pub use stream::{v3, v5, MqttStream};
65
66/// Convenience type alias for generic errors
67pub type Error = anyhow::Error;
68
69/// Result type alias using crate's Error type
70pub type Result<T> = anyhow::Result<T, Error>;