This pull request introduces several key changes to the MQTT packet handling in the src/main.rs and src/packet.rs files. The changes include improvements to packet decoding, adjustments to buffer sizes, and enhancements to the MqttPublish struct and its methods.
Packet Handling Enhancements:
src/main.rs: Modified the buffer size from 2 bytes to 1 byte and added detailed logging for the PUBLISH packet, including decoding the packet and printing the topic and payload.
src/packet.rs: Added necessary imports for TcpSocket, TcpStream, AsyncReadExt, and AsyncWriteExt to support asynchronous operations.
MqttPublish Struct Enhancements:
src/packet.rs: Updated the MqttPublish struct to include a qos field and changed the payload type from Vec<u8> to String.
src/packet.rs: Added a new constructor method new for initializing MqttPublish instances with all necessary fields.
src/packet.rs: Implemented a new decode method for MqttPublish to asynchronously decode a packet from a TCP stream, extracting the topic and payload.
This pull request introduces several key changes to the MQTT packet handling in the
src/main.rs
andsrc/packet.rs
files. The changes include improvements to packet decoding, adjustments to buffer sizes, and enhancements to theMqttPublish
struct and its methods.Packet Handling Enhancements:
src/main.rs
: Modified the buffer size from 2 bytes to 1 byte and added detailed logging for thePUBLISH
packet, including decoding the packet and printing the topic and payload.src/packet.rs
: Added necessary imports forTcpSocket
,TcpStream
,AsyncReadExt
, andAsyncWriteExt
to support asynchronous operations.MqttPublish
Struct Enhancements:src/packet.rs
: Updated theMqttPublish
struct to include aqos
field and changed thepayload
type fromVec<u8>
toString
.src/packet.rs
: Added a new constructor methodnew
for initializingMqttPublish
instances with all necessary fields.src/packet.rs
: Implemented a newdecode
method forMqttPublish
to asynchronously decode a packet from a TCP stream, extracting the topic and payload.