pub struct Will { /* private fields */ }Expand description
A message the broker publishes on the client’s behalf if the client’s connection ends
without a DISCONNECT: the network dropped, the power failed, or the keep-alive ran
out.
A device that publishes online to a status topic when it connects usually leaves a
will of offline on the same topic, retained, so anyone watching sees it go (OASIS MQTT
3.1.1, section 3.1.2.5). A client that disconnects on purpose leaves no will behind.
§Examples
use pamoja_mqtt::{MqttConfig, QualityOfService, Will};
let will = Will::new("sites/pump-3/status", b"offline")
.qos(QualityOfService::AtLeastOnce)
.retained();
let config = MqttConfig::new("pump-3", "localhost", 1883).last_will(will);
assert_eq!(config.will().map(Will::topic), Some("sites/pump-3/status"));Implementations§
Source§impl Will
impl Will
Sourcepub fn qos(self, qos: QualityOfService) -> Will
pub fn qos(self, qos: QualityOfService) -> Will
Sourcepub fn retained(self) -> Will
pub fn retained(self) -> Will
Has the broker retain the will, so a client that subscribes later still sees it.
§Returns
The updated will, for chaining.
Sourcepub fn quality_of_service(&self) -> QualityOfService
pub fn quality_of_service(&self) -> QualityOfService
Sourcepub fn is_retained(&self) -> bool
pub fn is_retained(&self) -> bool
Trait Implementations§
impl Eq for Will
impl StructuralPartialEq for Will
Auto Trait Implementations§
impl Freeze for Will
impl RefUnwindSafe for Will
impl Send for Will
impl Sync for Will
impl Unpin for Will
impl UnsafeUnpin for Will
impl UnwindSafe for Will
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