[−][src]Struct rumq_client::MqttState
MqttState
saves the state of the mqtt connection. Methods will
just modify the state of the object without doing any network operations
Methods returns so that n/w methods or n/w eventloop can
operate directly. This abstracts the functionality better
so that it's easy to switch between synchronous code, tokio (or)
async/await
Fields
connection_status: MqttConnectionStatus
Connection status
await_pingresp: bool
Status of last ping
last_incoming: Instant
Last incoming packet time
last_outgoing: Instant
Last outgoing packet time
last_pkid: PacketIdentifier
Packet id of the last outgoing packet
outgoing_pub: VecDeque<Publish>
Outgoing QoS 1, 2 publishes which aren't acked yet
outgoing_rel: VecDeque<PacketIdentifier>
Packet ids of released QoS 2 publishes
incoming_pub: VecDeque<PacketIdentifier>
Packet ids on incoming QoS 2 publishes
Methods
impl MqttState
[src]
pub fn new() -> Self
[src]
Creates new mqtt state. Same state should be used during a connection for persistent sessions while new state should instantiated for clean sessions
pub fn handle_packet(
&mut self,
packet: Packet
) -> Result<(Option<Notification>, Option<Packet>), StateError>
[src]
&mut self,
packet: Packet
) -> Result<(Option<Notification>, Option<Packet>), StateError>
pub fn handle_request(
&mut self,
request: Packet
) -> Result<(Option<Notification>, Option<Packet>), StateError>
[src]
&mut self,
request: Packet
) -> Result<(Option<Notification>, Option<Packet>), StateError>
pub fn handle_outgoing_mqtt_packet(
&mut self,
packet: Packet
) -> Result<Packet, StateError>
[src]
&mut self,
packet: Packet
) -> Result<Packet, StateError>
Consolidates handling of all outgoing mqtt packet logic. Returns a packet which should be put on to the network by the eventloop
pub fn handle_incoming_mqtt_packet(
&mut self,
packet: Packet
) -> Result<(Option<Notification>, Option<Packet>), StateError>
[src]
&mut self,
packet: Packet
) -> Result<(Option<Notification>, Option<Packet>), StateError>
Consolidates handling of all incoming mqtt packets. Returns a Notification
which for the
user to consume and Packet
which for the eventloop to put on the network
E.g For incoming QoS1 publish packet, this method returns (Publish, Puback). Publish packet will
be forwarded to user and Pubck packet will be written to network
pub fn handle_outgoing_publish(
&mut self,
publish: Publish
) -> Result<Packet, StateError>
[src]
&mut self,
publish: Publish
) -> Result<Packet, StateError>
Adds next packet identifier to QoS 1 and 2 publish packets and returns it buy wrapping publish in packet
pub fn handle_incoming_puback(
&mut self,
pkid: PacketIdentifier
) -> Result<(Option<Notification>, Option<Packet>), StateError>
[src]
&mut self,
pkid: PacketIdentifier
) -> Result<(Option<Notification>, Option<Packet>), StateError>
Iterates through the list of stored publishes and removes the publish with the matching packet identifier. Removal is now a O(n) operation. This should be usually ok in case of acks due to ack ordering in normal conditions. But in cases where the broker doesn't guarantee the order of acks, the performance won't be optimal
pub fn handle_incoming_suback(
&mut self,
suback: Suback
) -> Result<(Option<Notification>, Option<Packet>), StateError>
[src]
&mut self,
suback: Suback
) -> Result<(Option<Notification>, Option<Packet>), StateError>
pub fn handle_incoming_unsuback(
&mut self,
pkid: PacketIdentifier
) -> Result<(Option<Notification>, Option<Packet>), StateError>
[src]
&mut self,
pkid: PacketIdentifier
) -> Result<(Option<Notification>, Option<Packet>), StateError>
pub fn handle_incoming_pubrec(
&mut self,
pkid: PacketIdentifier
) -> Result<(Option<Notification>, Option<Packet>), StateError>
[src]
&mut self,
pkid: PacketIdentifier
) -> Result<(Option<Notification>, Option<Packet>), StateError>
Iterates through the list of stored publishes and removes the publish with the matching packet identifier. Removal is now a O(n) operation. This should be usually ok in case of acks due to ack ordering in normal conditions. But in cases where the broker doesn't guarantee the order of acks, the performance won't be optimal
pub fn handle_incoming_publish(
&mut self,
publish: Publish
) -> Result<(Option<Notification>, Option<Packet>), StateError>
[src]
&mut self,
publish: Publish
) -> Result<(Option<Notification>, Option<Packet>), StateError>
Results in a publish notification in all the QoS cases. Replys with an ack in case of QoS1 and Replys rec in case of QoS while also storing the message
pub fn handle_outgoing_ping(&mut self) -> Result<Packet, StateError>
[src]
check when the last control packet/pingreq packet is received and return the status which tells if keep alive time has exceeded NOTE: status will be checked for zero keepalive times also
pub fn handle_outgoing_connect(&mut self) -> Result<(), StateError>
[src]
pub fn handle_incoming_connack(
&mut self,
packet: Packet
) -> Result<(), StateError>
[src]
&mut self,
packet: Packet
) -> Result<(), StateError>
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for MqttState
impl Send for MqttState
impl Sync for MqttState
impl Unpin for MqttState
impl UnwindSafe for MqttState
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,