[][src]Enum mqttrs::Packet

pub enum Packet<'a> {
    Connect(Connect<'a>),
    Connack(Connack),
    Publish(Publish<'a>),
    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_slice() 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",
                        payload: b"payload" };
let pkt: Packet = publish.into();
// Identifyer-only packets
let pkt = Packet::Puback(Pid::try_from(42).unwrap());

Variants

Connect(Connect<'a>)
Connack(Connack)
Publish(Publish<'a>)
Puback(Pid)
Pubrec(Pid)
Pubrel(Pid)
Pubcomp(Pid)
Subscribe(Subscribe)
Suback(Suback)
Unsubscribe(Unsubscribe)
Unsuback(Pid)
Pingreq
Pingresp
Disconnect

Implementations

impl<'a> Packet<'a>[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<'a> Clone for Packet<'a>[src]

impl<'a> Debug for Packet<'a>[src]

impl<'a> From<Connack> for Packet<'a>[src]

impl<'a> From<Connect<'a>> for Packet<'a>[src]

impl<'a> From<Publish<'a>> for Packet<'a>[src]

impl<'a> From<Suback> for Packet<'a>[src]

impl<'a> From<Subscribe> for Packet<'a>[src]

impl<'a> From<Unsubscribe> for Packet<'a>[src]

impl<'a> PartialEq<Packet<'a>> for Packet<'a>[src]

impl<'a> StructuralPartialEq for Packet<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Packet<'a>

impl<'a> Send for Packet<'a>

impl<'a> Sync for Packet<'a>

impl<'a> Unpin for Packet<'a>

impl<'a> UnwindSafe for Packet<'a>

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> Same<T> for T

type Output = T

Should always be Self

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.