mqute_codec/protocol/v5/
ping.rs

1//! # Ping Request and Response Packets V5
2//!
3//! This module implements the MQTT PingReq (Ping Request) and PingResp (Ping Response) packets.
4//! These packets are used to maintain the connection between client and server when no other
5//! packets are being sent, and to verify that the connection is still active.
6//!
7//! The PingReq packet is sent by a client to the server to:
8//! 1. Indicate that the client is alive when no other packets are being sent
9//! 2. Verify that the server is available and responding
10//!
11//! The PingResp packet is sent by the server in response to a PingReq to:
12//! 1. Acknowledge the ping request
13//! 2. Confirm that the server is still alive and responsive
14//!
15//! The PingReq and PingResp packet have no payload or variable header - they consist only of a
16//! fixed header.
17
18use super::util;
19use crate::protocol::PacketType;
20
21/// Represents an MQTT PingReq (Ping Request) packet.
22///
23/// # Example
24///
25/// ```rust
26/// use mqute_codec::protocol::v5::PingReq;
27///
28/// let packet = PingReq { };
29/// ```
30#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
31pub struct PingReq {}
32
33// Implements encoding/decoding using ping packet macros
34util::ping_packet_decode_impl!(PingReq, PacketType::PingReq);
35util::ping_packet_encode_impl!(PingReq, PacketType::PingReq);
36
37/// Represents an MQTT PingResp (Ping Response) packet.
38///
39/// # Example
40///
41/// ```rust
42/// use mqute_codec::protocol::v5::PingResp;
43///
44/// let packet = PingResp { };
45/// ```
46#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
47pub struct PingResp {}
48
49// Implements encoding/decoding using ping packet macros
50util::ping_packet_decode_impl!(PingResp, PacketType::PingResp);
51util::ping_packet_encode_impl!(PingResp, PacketType::PingResp);