pub enum Packet {
}
Expand description
MQTT v3.x packet types.
Variants§
Connect(Connect)
Connack(Connack)
Publish(Publish)
Puback(Pid)
Pubrec(Pid)
Pubrel(Pid)
Pubcomp(Pid)
Subscribe(Subscribe)
Suback(Suback)
Unsubscribe(Unsubscribe)
Unsuback(Pid)
Pingreq
Pingresp
Disconnect
Implementations§
Source§impl Packet
impl Packet
Sourcepub fn get_type(&self) -> PacketType
pub fn get_type(&self) -> PacketType
Return the packet type variant.
This can be used for matching, categorising, debuging, etc. Most users
will match directly on Packet
instead.
Sourcepub async fn decode_async<T: AsyncRead + Unpin>(
reader: &mut T,
) -> Result<Self, Error>
pub async fn decode_async<T: AsyncRead + Unpin>( reader: &mut T, ) -> Result<Self, Error>
Asynchronously decode a packet from an async reader.
Sourcepub async fn encode_async<T: AsyncWrite + Unpin>(
&self,
writer: &mut T,
) -> Result<(), Error>
pub async fn encode_async<T: AsyncWrite + Unpin>( &self, writer: &mut T, ) -> Result<(), Error>
Asynchronously encode the packet to an async writer.
Sourcepub fn decode(bytes: &[u8]) -> Result<Option<Self>, Error>
pub fn decode(bytes: &[u8]) -> Result<Option<Self>, Error>
Decode a packet from some bytes. If not enough bytes to decode a packet,
it will return Ok(None)
.
Sourcepub fn encode(&self) -> Result<VarBytes, Error>
pub fn encode(&self) -> Result<VarBytes, Error>
Encode the packet to a dynamic vector or fixed array.
Sourcepub fn encode_len(&self) -> Result<usize, Error>
pub fn encode_len(&self) -> Result<usize, Error>
Return the total length of bytes the packet encoded into.
Trait Implementations§
Source§impl From<Unsubscribe> for Packet
impl From<Unsubscribe> for Packet
Source§fn from(p: Unsubscribe) -> Self
fn from(p: Unsubscribe) -> Self
Converts to this type from the input type.
impl Eq for Packet
impl StructuralPartialEq for Packet
Auto Trait Implementations§
impl !Freeze for Packet
impl RefUnwindSafe for Packet
impl Send for Packet
impl Sync for Packet
impl Unpin for Packet
impl UnwindSafe for Packet
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