pub struct Header {
pub packet_type: PacketType,
pub sequence_number: u8,
pub pixel_config: PixelConfig,
pub id: ID,
pub offset: u32,
pub length: u16,
pub time_code: TimeCode,
}Expand description
DDP packet header containing metadata and control flags.
The header is 10 bytes (or 14 with timecode) and contains all the information needed to interpret the packet payload.
§Examples
use ddp_rs::protocol::{Header, PacketType, PixelConfig, ID, timecode::TimeCode};
let header = Header {
packet_type: PacketType::default(),
sequence_number: 1,
pixel_config: PixelConfig::default(),
id: ID::Default,
offset: 0,
length: 9,
time_code: TimeCode(None),
};
// Convert to bytes for transmission
let bytes: [u8; 10] = header.into();Fields§
§packet_type: PacketTypePacket type flags (version, timecode, storage, reply, query, push)
sequence_number: u8Sequence number (1-15, wraps around to 1)
pixel_config: PixelConfigPixel format configuration (RGB, RGBW, etc.)
id: IDProtocol message ID
offset: u32Byte offset into the display buffer
length: u16Length of data in this packet (in bytes)
time_code: TimeCodeOptional timecode for synchronization (if timecode flag is set)
Implementations§
Source§impl Header
impl Header
Sourcepub fn write_into(&self, buf: &mut [u8]) -> usize
pub fn write_into(&self, buf: &mut [u8]) -> usize
Serializes this header into the start of buf, returning the number of bytes written
(10, or 14 when a timecode is present).
This is the allocation-free, no_std-friendly equivalent of the Into<[u8; 10]> /
Into<[u8; 14]> conversions — useful when writing a packet directly into a reusable
transmit buffer.
§Panics
Panics if buf is shorter than the required header length.
§Examples
use ddp_rs::protocol::Header;
let header = Header::default();
let mut buf = [0u8; 10];
let n = header.write_into(&mut buf);
assert_eq!(n, 10);