Struct PayloadHeader

Source
pub struct PayloadHeader {
    pub if_type: InterfaceType,
    pub if_num: u8,
    pub flags: u8,
    pub len: u16,
    pub offset: u16,
    pub checksum: u16,
    pub seq_num: u16,
    pub throttle_cmd: u8,
    pub pkt_type: PacketType,
}
Expand description

Adapted from esp-hosted-mcu/common/esp_hosted_header.h This is at the start of the message, and is followed by the RPC header. See ESP-hosted-MCU readme, section 7.1.

Fields§

§if_type: InterfaceType

Interface type. Serial, AP etc.

§if_num: u8

Interface number. 0 may be a good default?

§flags: u8§len: u16

Payload length. The size, in bytes, of everything in the frame following this header

§offset: u16

Offset. Always = 12 (This header’s size). Indicates the byte index the payload starts.

§checksum: u16

Checksum, calculated over the entire frame.

§seq_num: u16

Sequence number for tracking packets (Useful in debugging)

§throttle_cmd: u8

Flow control

§pkt_type: PacketType

Implementations§

Source§

impl PayloadHeader

Source

pub fn new( if_type: InterfaceType, if_num: u8, pkt_type: PacketType, payload_len: usize, ) -> Self

Source

pub fn to_bytes(&self) -> [u8; 12]

Serialize into the 12-byte packed representation

Source

pub fn from_bytes(buf: &[u8]) -> Result<Self, EspError>

Parse from a 12-byte slice (will panic if buf.len() < 12 or slice-to-array fails)

Trait Implementations§

Source§

impl Format for PayloadHeader
where InterfaceType: Format, PacketType: Format,

Source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.

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> 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, 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.