DataPhasePacket

Struct DataPhasePacket 

Source
pub struct DataPhasePacket {
    pub data: Vec<u8>,
}
Expand description

McuBoot data phase packet structure

Represents a data phase packet that carries additional data for commands that require it. The data phase packet is sent after the command packet when the command’s CommandFlag::HasDataPhase flag is set. This allows for transmission of variable-length data that exceeds the command packet’s parameter capacity.

§Usage

If using the McuBoot high-level interface, data phase packets are automatically sent when a command requires additional data. However, if you’re working with command packets directly, you’ll need to create and send the corresponding data phase packet manually for commands that have the CommandFlag::HasDataPhase flag set.

Fields§

§data: Vec<u8>

Raw data payload to be transmitted

Trait Implementations§

Source§

impl Packet for DataPhasePacket

Source§

fn get_code() -> u8

Returns the packet type identifier for data phase packets (0xA5)

Source§

impl PacketConstruct for DataPhasePacket

Source§

fn construct(&self) -> Vec<u8>

Constructs a complete data phase packet ready for transmission

This method wraps the data payload with the appropriate McuBoot protocol header to create a properly formatted data phase packet. The header includes the packet type, length, and CRC checksum as required by the protocol.

§Returns

A Vec<u8> containing the complete data phase packet with protocol header:

  • Start byte (0x5A)
  • Packet code (0xA5)
  • Length (2 bytes, little-endian)
  • CRC16 (2 bytes, little-endian)
  • Data payload (variable length)
Source§

impl PacketParse for DataPhasePacket

Source§

fn parse(bytes: &[u8]) -> Result<DataPhasePacket, CommunicationError>

Creates a DataPhasePacket from raw bytes

§Arguments
  • bytes - Raw data bytes to be stored in the packet
§Returns

A Result containing the new DataPhasePacket with the provided data

§Note

This method always succeeds as data phase packets can contain any arbitrary byte sequence as their payload.

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.