1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#![cfg_attr(docsrs, feature(doc_cfg))]
//! This crate implements an async MQTT client using libmosquitto.
//!
//! ```no_run
//! use mosquitto_rs::*;
//!
//! fn main() -> Result<(), Error> {
//! smol::block_on(async {
//! let mut client = Client::with_auto_id()?;
//! let rc = client.connect(
//! "localhost", 1883,
//! std::time::Duration::from_secs(5), None).await?;
//! println!("connect: {}", rc);
//!
//! let subscriptions = client.subscriber().unwrap();
//!
//! client.subscribe("test", QoS::AtMostOnce).await?;
//! println!("subscribed");
//!
//! client.publish("test", b"woot", QoS::AtMostOnce, false)
//! .await?;
//! println!("published");
//!
//! if let Ok(msg) = subscriptions.recv().await {
//! println!("msg: {:?}", msg);
//! }
//!
//! Ok(())
//! })
//! }
//! ```
//!
//! ## Features
//!
//! The following feature flags are available:
//!
//! * `router` - include the router module and `MqttRouter` type. This is on by default.
//! * `vendored-mosquitto` - use bundled libmosquitto 2.4 library. This is on by default.
//! * `vendored-mosquitto-tls` - enable tls support in the bundled libmosquitto. This is on by default.
//! * `vendored-openssl` - build openssl from source, rather than using the system library. Recommended for macOS and Windows users to enable this.
mod client;
mod error;
mod lowlevel;
#[cfg_attr(docsrs, doc(cfg(feature = "router")))]
#[cfg(feature = "router")]
pub mod router;
pub use client::*;
pub use error::*;
pub use lowlevel::*;