pub struct SubscriptionId(/* private fields */);Expand description
Unique identifier for a subscription.
This ID is returned when creating a subscription and can be used to unsubscribe later. IDs are unique within a device’s lifetime.
§Examples
use tasmor_lib::MqttBroker;
use tasmor_lib::subscription::Subscribable;
let broker = MqttBroker::builder()
.host("192.168.1.50")
.build()
.await?;
let (device, _) = broker.device("tasmota_device")
.build()
.await?;
let sub_id = device.on_power_changed(|idx, state| {
println!("Relay {idx} changed to {state:?}");
});
// Later, unsubscribe
device.unsubscribe(sub_id);Implementations§
Trait Implementations§
Source§impl Clone for SubscriptionId
impl Clone for SubscriptionId
Source§fn clone(&self) -> SubscriptionId
fn clone(&self) -> SubscriptionId
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SubscriptionId
impl Debug for SubscriptionId
Source§impl Display for SubscriptionId
impl Display for SubscriptionId
Source§impl Hash for SubscriptionId
impl Hash for SubscriptionId
Source§impl PartialEq for SubscriptionId
impl PartialEq for SubscriptionId
impl Copy for SubscriptionId
impl Eq for SubscriptionId
impl StructuralPartialEq for SubscriptionId
Auto Trait Implementations§
impl Freeze for SubscriptionId
impl RefUnwindSafe for SubscriptionId
impl Send for SubscriptionId
impl Sync for SubscriptionId
impl Unpin for SubscriptionId
impl UnwindSafe for SubscriptionId
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.