Skip to main content

Packet

Enum Packet 

Source
pub enum Packet {
    PushData {
        token: u16,
        gateway: Eui,
        uplink: Uplink,
    },
    PushAck {
        token: u16,
    },
    PullData {
        token: u16,
        gateway: Eui,
    },
    PullAck {
        token: u16,
    },
    PullResp {
        token: u16,
        transmit: Txpk,
    },
    TxAck {
        token: u16,
        gateway: Eui,
        status: TxStatus,
    },
}
Expand description

One datagram of the protocol.

to_bytes writes it and parse reads one, so the same type serves a gateway and a server.

Variants§

§

PushData

What the gateway heard, and how its own radio is doing.

Fields

§token: u16

The random token the acknowledgment carries back.

§gateway: Eui

The gateway’s identifier.

§uplink: Uplink

The packets and the status report.

§

PushAck

The server acknowledging a PUSH_DATA, which says only that it arrived.

Fields

§token: u16

The token of the PUSH_DATA being acknowledged.

§

PullData

The gateway holding a route open for downlinks.

Fields

§token: u16

The random token the acknowledgment carries back.

§gateway: Eui

The gateway’s identifier.

§

PullAck

The server acknowledging a PULL_DATA.

Fields

§token: u16

The token of the PULL_DATA being acknowledged.

§

PullResp

The server asking the gateway to transmit a packet.

Fields

§token: u16

The random token the TX_ACK carries back.

§transmit: Txpk

What to transmit, and when.

§

TxAck

The gateway reporting what became of a PULL_RESP.

Fields

§token: u16

The token of the PULL_RESP being answered.

§gateway: Eui

The gateway’s identifier.

§status: TxStatus

Whether it was scheduled, or why it was refused.

Implementations§

Source§

impl Packet

Source

pub const fn kind(&self) -> PacketKind

Returns which kind of datagram this is.

§Returns

The kind.

Source

pub const fn token(&self) -> u16

Returns the token, which pairs a datagram with its answer.

§Returns

The token.

Source

pub const fn gateway(&self) -> Option<Eui>

Returns the gateway’s identifier, for the kinds that carry it.

§Returns

The identifier, or None for the datagrams a server sends, which do not name one.

Source

pub fn acknowledgment(&self) -> Option<Packet>

Returns the acknowledgment a server owes this datagram.

§Returns

The PUSH_ACK or PULL_ACK to send back, or None for a datagram that is itself an answer. A PULL_RESP is answered with a TX_ACK, which names the gateway and what became of the transmission, so the gateway builds that one itself.

Source

pub fn to_bytes(&self) -> Vec<u8>

Writes the datagram.

§Returns

The bytes to send.

Source

pub fn parse(bytes: &[u8]) -> Result<Packet, ProtocolError>

Reads a datagram.

§Arguments
  • bytes - the datagram as it arrived.
§Returns

The packet.

§Errors

Returns ProtocolError for a datagram shorter than its header, another protocol version, an identifier the protocol does not define, a datagram missing the fields its kind carries, or a payload that is not the JSON object described for it.

Trait Implementations§

Source§

impl Clone for Packet

Source§

fn clone(&self) -> Packet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 PartialEq for Packet

Source§

fn eq(&self, other: &Packet) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Packet

Auto Trait Implementations§

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

Source§

type Output = T

Should always be Self
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, 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.