pub struct Connection { /* private fields */ }Expand description
An open connection to an MQTT queue.
The address must be in URL form, and must include a client_id:
mqtt://hostname?client_id=...
§Examples
Send an MQTT message.
use spin_sdk::mqtt::{Connection, Qos};
let user = spin_sdk::variables::get("mqtt_username")?;
let password = spin_sdk::variables::get("mqtt_password")?;
let conn = Connection::open(
"mqtt://localhost:1883?client_id=123",
&user,
&password,
30 /* seconds */
)?;
let payload = request.body().to_vec();
ensure_pet_picture(&payload)?;
conn.publish("pet-pictures", &payload, Qos::AtLeastOnce)?;Implementations§
Source§impl Connection
impl Connection
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Connection
impl RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnwindSafe for Connection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more