pub struct Subscribe { /* private fields */ }Expand description
Represents an MQTT v5 Subscribe packet
Used to request subscription to one or more topics with various options:
- QoS levels
- Retain handling preferences
- Local message filtering
§Example
use mqute_codec::protocol::v5::{Subscribe, TopicOptionFilter, RetainHandling};
use mqute_codec::protocol::QoS;
let subscribe = Subscribe::new(
1234,
None,
vec![
TopicOptionFilter::new(
"sensors/temperature",
QoS::AtLeastOnce,
false,
true,
RetainHandling::Send
),
TopicOptionFilter::new(
"control/#",
QoS::ExactlyOnce,
true,
false,
RetainHandling::SendForNewSub
)
]
);
let filters = subscribe.filters();
assert_eq!(filters[0],
TopicOptionFilter::new(
"sensors/temperature",
QoS::AtLeastOnce,
false,
true,
RetainHandling::Send
));Implementations§
Source§impl Subscribe
impl Subscribe
Sourcepub fn new<T: IntoIterator<Item = TopicOptionFilter>>(
packet_id: u16,
properties: Option<SubscribeProperties>,
filters: T,
) -> Self
pub fn new<T: IntoIterator<Item = TopicOptionFilter>>( packet_id: u16, properties: Option<SubscribeProperties>, filters: T, ) -> Self
Creates a new Subscribe packet
Sourcepub fn properties(&self) -> Option<SubscribeProperties>
pub fn properties(&self) -> Option<SubscribeProperties>
Returns the subscription properties
Sourcepub fn filters(&self) -> TopicOptionFilters
pub fn filters(&self) -> TopicOptionFilters
Returns the collection of topic filters
Trait Implementations§
impl Eq for Subscribe
impl StructuralPartialEq for Subscribe
impl Subscribe for Subscribe
Auto Trait Implementations§
impl Freeze for Subscribe
impl RefUnwindSafe for Subscribe
impl Send for Subscribe
impl Sync for Subscribe
impl Unpin for Subscribe
impl UnwindSafe for Subscribe
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> Encoded for Twhere
T: Encode,
impl<T> Encoded for Twhere
T: Encode,
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Calculates the total encoded length of the packet. Read more