[][src]Struct mqttrs::Pid

pub struct Pid(_);

Packet Identifier.

For packets with QoS::AtLeastOne or QoS::ExactlyOnce delivery.

#[derive(Default)]
struct Session {
   pid: Pid,
}
impl Session {
   pub fn next_pid(&mut self) -> Pid {
       self.pid = self.pid + 1;
       self.pid
   }
}

let mut sess = Session::default();
assert_eq!(2, sess.next_pid().get());
assert_eq!(Pid::try_from(3).unwrap(), sess.next_pid());

The spec (MQTT-2.3.1-1, MQTT-2.2.1-3) disallows a pid of 0.

Implementations

impl Pid[src]

pub fn new() -> Self[src]

Returns a new Pid with value 1.

pub fn get(self) -> u16[src]

Get the Pid as a raw u16.

Trait Implementations

impl Add<u16> for Pid[src]

type Output = Pid

The resulting type after applying the + operator.

pub fn add(self, u: u16) -> Pid[src]

Adding a u16 to a Pid will wrap around and avoid 0.

impl Clone for Pid[src]

impl Copy for Pid[src]

impl Debug for Pid[src]

impl Default for Pid[src]

impl Eq for Pid[src]

impl From<Pid> for u16[src]

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

Convert Pid to u16.

impl Hash for Pid[src]

impl Ord for Pid[src]

impl PartialEq<Pid> for Pid[src]

impl PartialOrd<Pid> for Pid[src]

impl StructuralEq for Pid[src]

impl StructuralPartialEq for Pid[src]

impl Sub<u16> for Pid[src]

type Output = Pid

The resulting type after applying the - operator.

pub fn sub(self, u: u16) -> Pid[src]

Adding a u16 to a Pid will wrap around and avoid 0.

impl TryFrom<u16> for Pid[src]

type Error = Error

The type returned in the event of a conversion error.

pub fn try_from(u: u16) -> Result<Self, Error>[src]

Convert u16 to Pid. Will fail for value 0.

Auto Trait Implementations

impl RefUnwindSafe for Pid

impl Send for Pid

impl Sync for Pid

impl Unpin for Pid

impl UnwindSafe for Pid

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.