mosquitto-rs 0.1.0

Unsafe FFI bindings to libmosquitto
docs.rs failed to build mosquitto-rs-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: mosquitto-rs-0.11.1

An async MQTT client

This crate implements an async MQTT client using libmosquitto.

use mosquitto_rs::*;

fn main() -> Result<(), Error> {
    smol::block_on(async {
        let mut mosq = Client::with_auto_id()?;
        let rc = mosq.connect("localhost", 1883, std::time::Duration::from_secs(5), None).await?;
        println!("connect: {}", rc);

        let subscriptions = mosq.subscriber().unwrap();

        mosq.subscribe("test", QoS::AtMostOnce).await?;
        println!("subscribed");

        mosq.publish("test", b"woot", QoS::AtMostOnce, false)
            .await?;
        println!("published");

        if let Ok(msg) = subscriptions.recv().await {
            println!("msg: {:?}", msg);
        }

        Ok(())
    })
}