Enum Packet

Source
pub enum Packet {
Show 15 variants Connect(Connect), ConnAck(ConnAck), Publish(Publish), PubAck(PubAck), PubRec(PubRec), PubRel(PubRel), PubComp(PubComp), Subscribe(Subscribe), SubAck(SubAck), UnSubscribe(UnSubscribe), UnSubAck(UnSubAck), PingReq, PingResp, Disconnect(Disconnect), Auth(Auth),
}
Expand description

The standard type to manipulate a AsyncRead/AsyncWrite-able MQTT packet. Each packet is an enum value with its own type.

Variants§

§

Connect(Connect)

CONNECT MQTT packet. Opens a connection request.

§

ConnAck(ConnAck)

CONNACK MQTT packet. Aknowledge a connectio request.

§

Publish(Publish)

PUBLISH MQTT packet. Delivery a message to or from a server.

§

PubAck(PubAck)

PUBACK MQTT packet. Ackowledge a QoS 1 or QoS 2 message.

§

PubRec(PubRec)

PUBREC MQTT packet. Ackowledge a QoS 2 message.

§

PubRel(PubRel)

PUBREL MQTT packet. Ackowledge a QoS 2 message.

§

PubComp(PubComp)

PUBCOMP MQTT packet. Ackowledge a QoS 2 message.

§

Subscribe(Subscribe)

SUBSCRIBE MQTT packet. Subscribe a client to topics.

§

SubAck(SubAck)

SUBACK MQTT packet. Acknowledge a client SUBSCRIBE packet.

§

UnSubscribe(UnSubscribe)

UNSUBSCRIBE MQTT packet. Unsubscribe a client from topics.

§

UnSubAck(UnSubAck)

UNSUBACK MQTT packet. Acknowledge a client UNSUBSCRIBE packet.

§

PingReq

PINGREQ MQTT packet. Send a ping request.

§

PingResp

PINGRESP MQTT packet. Respond to a ping request.

§

Disconnect(Disconnect)

DISCONNECT MQTT packet. Disconnect a connextion and optionally a session.

§

Auth(Auth)

AUTH MQTT packet. Performs authentication exchanges between clients and server.

Implementations§

Source§

impl Packet

Source

pub async fn encode<W: AsyncWrite + Unpin>( self, writer: &mut W, ) -> SageResult<usize>

Write the entire Packet to writer, returning the number of bytes written. In case of failure, the operation will return any MQTT-related error, or std::io::Error.

Source

pub async fn decode<R: AsyncRead + Unpin>(reader: &mut R) -> SageResult<Self>

Read a control packet from reader, returning a new Packet. In case of failure, the operation will return any MQTT-related error, or std::io::Error.

Trait Implementations§

Source§

impl Clone for Packet

Source§

fn clone(&self) -> Packet

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Packet

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for Packet

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<Auth> for Packet

Source§

fn from(control: Auth) -> Self

Converts to this type from the input type.
Source§

impl From<ConnAck> for Packet

Source§

fn from(control: ConnAck) -> Self

Converts to this type from the input type.
Source§

impl From<Connect> for Packet

Source§

fn from(control: Connect) -> Self

Converts to this type from the input type.
Source§

impl From<Disconnect> for Packet

Source§

fn from(control: Disconnect) -> Self

Converts to this type from the input type.
Source§

impl From<PingReq> for Packet

Source§

fn from(_: PingReq) -> Self

Converts to this type from the input type.
Source§

impl From<PingResp> for Packet

Source§

fn from(_: PingResp) -> Self

Converts to this type from the input type.
Source§

impl From<PubAck> for Packet

Source§

fn from(control: PubAck) -> Self

Converts to this type from the input type.
Source§

impl From<PubComp> for Packet

Source§

fn from(control: PubComp) -> Self

Converts to this type from the input type.
Source§

impl From<PubRec> for Packet

Source§

fn from(control: PubRec) -> Self

Converts to this type from the input type.
Source§

impl From<PubRel> for Packet

Source§

fn from(control: PubRel) -> Self

Converts to this type from the input type.
Source§

impl From<Publish> for Packet

Source§

fn from(control: Publish) -> Self

Converts to this type from the input type.
Source§

impl From<SubAck> for Packet

Source§

fn from(control: SubAck) -> Self

Converts to this type from the input type.
Source§

impl From<Subscribe> for Packet

Source§

fn from(control: Subscribe) -> Self

Converts to this type from the input type.
Source§

impl From<UnSubAck> for Packet

Source§

fn from(control: UnSubAck) -> Self

Converts to this type from the input type.
Source§

impl From<UnSubscribe> for Packet

Source§

fn from(control: UnSubscribe) -> Self

Converts to this type from the input type.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.