Enum mqttrs::Packet[][src]

pub enum Packet<'a> {
Show 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,
}
Expand description

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]

fn clone(&self) -> Packet<'a>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

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

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

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

fn from(p: Connack) -> Self[src]

Performs the conversion.

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

fn from(p: Connect<'a>) -> Self[src]

Performs the conversion.

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

fn from(p: Publish<'a>) -> Self[src]

Performs the conversion.

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

fn from(p: Suback) -> Self[src]

Performs the conversion.

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

fn from(p: Subscribe) -> Self[src]

Performs the conversion.

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

fn from(p: Unsubscribe) -> Self[src]

Performs the conversion.

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

fn eq(&self, other: &Packet<'a>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Packet<'a>) -> bool[src]

This method tests for !=.

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.