[][src]Enum mqttrs::Packet

pub enum Packet {
    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,
}

Base enum for all MQTT packet types.

This is the main type you'll be interacting with, as an output of decode() and an input of encode(). Most variants can be constructed directly without using methods.

// Simplest form
let pkt = Packet::Connack(Connack { session_present: false,
                                    code: ConnectReturnCode::Accepted });
// Using `Into` trait
let publish = Publish { dup: false,
                        qospid: QosPid::AtMostOnce,
                        retain: false,
                        topic_name: "to/pic".into(),
                        payload: "payload".into() };
let pkt: Packet = publish.into();
// Identifyer-only packets
let pkt = Packet::Puback(Pid::try_from(42).unwrap());

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

Methods

impl Packet[src]

pub fn get_type(&self) -> PacketType[src]

Return the packet type variant.

This can be used for matching, categorising, debuging, etc. Most users will match directly on Packet instead.

Trait Implementations

impl Clone for Packet[src]

impl Debug for Packet[src]

impl From<Connack> for Packet[src]

impl From<Connect> for Packet[src]

impl From<Publish> for Packet[src]

impl From<Suback> for Packet[src]

impl From<Subscribe> for Packet[src]

impl From<Unsubscribe> for Packet[src]

impl PartialEq<Packet> for Packet[src]

impl StructuralPartialEq for Packet[src]

Auto Trait Implementations

impl RefUnwindSafe for Packet

impl Send for Packet

impl Sync for Packet

impl Unpin for Packet

impl UnwindSafe for Packet

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.