pub struct Client { /* private fields */ }Expand description
MQTT 3.1.1 client.
Wraps ove_mqtt_client_t with automatic cleanup on drop.
Implementations§
Source§impl Client
impl Client
Sourcepub fn create(storage: &mut ClientStorage) -> Result<Self>
pub fn create(storage: &mut ClientStorage) -> Result<Self>
Create a client that works in both heap and zero-heap modes.
Sourcepub fn connect(&mut self, cfg: &Config<'_>, on_message: MessageFn) -> Result<()>
pub fn connect(&mut self, cfg: &Config<'_>, on_message: MessageFn) -> Result<()>
Connect to an MQTT broker.
on_message is called for each incoming publish (topic + payload).
§Errors
Returns an error if the connection or MQTT handshake fails.
Sourcepub fn disconnect(&mut self)
pub fn disconnect(&mut self)
Disconnect from the MQTT broker.
Sourcepub fn publish(&self, topic: &[u8], payload: &[u8], qos: Qos) -> Result<()>
pub fn publish(&self, topic: &[u8], payload: &[u8], qos: Qos) -> Result<()>
Publish a message on a topic.
topic must be a null-terminated byte string.
§Errors
Returns an error if the publish fails.
Sourcepub fn subscribe(&self, topic: &[u8], qos: Qos) -> Result<()>
pub fn subscribe(&self, topic: &[u8], qos: Qos) -> Result<()>
Subscribe to a topic filter.
topic must be a null-terminated byte string.
§Errors
Returns an error if the subscribe fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl RefUnwindSafe for Client
impl !Sync for Client
impl Unpin for Client
impl UnwindSafe for Client
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