pub struct MqttPublisher<T, F> { /* private fields */ }
Expand description
Typed MQTT publisher for a specific topic.
Created via MqttClient::get_publisher()
. Supports QoS and retain configuration.
Implementations§
Source§impl<T, F> MqttPublisher<T, F>where
F: MessageSerializer<T>,
impl<T, F> MqttPublisher<T, F>where
F: MessageSerializer<T>,
Sourcepub fn new(
client: AsyncClient,
serializer: F,
topic: impl Into<ArcStr>,
) -> MqttPublisher<T, F>
pub fn new( client: AsyncClient, serializer: F, topic: impl Into<ArcStr>, ) -> MqttPublisher<T, F>
Internal constructor. Use MqttClient::get_publisher() instead.
Sourcepub fn with_qos(self, qos: QoS) -> MqttPublisher<T, F>
pub fn with_qos(self, qos: QoS) -> MqttPublisher<T, F>
Sets Quality of Service level for published messages.
Sourcepub fn with_retain(self, retain: bool) -> MqttPublisher<T, F>
pub fn with_retain(self, retain: bool) -> MqttPublisher<T, F>
Sets retain flag for published messages.
Sourcepub async fn publish(&self, data: &T) -> Result<(), MqttClientError>
pub async fn publish(&self, data: &T) -> Result<(), MqttClientError>
Publishes data to the configured topic.
Sourcepub async fn publish_retain(&self, data: &T) -> Result<(), MqttClientError>
pub async fn publish_retain(&self, data: &T) -> Result<(), MqttClientError>
Publishes data with retain flag explicitly set to true.
Sourcepub async fn publish_normal(&self, data: &T) -> Result<(), MqttClientError>
pub async fn publish_normal(&self, data: &T) -> Result<(), MqttClientError>
Publishes data with retain flag explicitly set to false.
Sourcepub async fn clear_retained(&self) -> Result<(), MqttClientError>
pub async fn clear_retained(&self) -> Result<(), MqttClientError>
Clear retained message for this topic
Sends an empty payload with retain=true to remove any retained message. Uses the same QoS level as configured for this publisher.
Auto Trait Implementations§
impl<T, F> Freeze for MqttPublisher<T, F>where
F: Freeze,
impl<T, F> RefUnwindSafe for MqttPublisher<T, F>where
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, F> Send for MqttPublisher<T, F>
impl<T, F> Sync for MqttPublisher<T, F>
impl<T, F> Unpin for MqttPublisher<T, F>
impl<T, F> UnwindSafe for MqttPublisher<T, F>where
F: UnwindSafe,
T: UnwindSafe,
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