pub struct Header {
pub packet_type: PacketType,
pub packet_count: u8,
pub superframe_idx: u8,
pub t2mi_stream_id: u8,
pub payload_len_bits: u16,
}Expand description
T2-MI packet header (6 bytes / 48 bits) per §5.1.
Layout:
- byte 0: packet_type (8 bits) — Table 1
- byte 1: packet_count (8 bits) — wraps 0xFF→0x00, arbitrary start
- byte 2
[7:4]: superframe_idx (4 bits) - byte 2
[3]: rfu (1 bit) — must be 0 - byte 2
[2:0]: t2mi_stream_id (3 bits) - byte 3: rfu (8 bits) — must be 0
- byte 4-5: payload_len (16 bits, unit = bits)
Fields§
§packet_type: PacketTypeTable 1 packet type.
packet_count: u8Wraps 0xFF→0x00; arbitrary start value.
superframe_idx: u8Super-frame index [0..=15].
t2mi_stream_id: u8T2-MI stream ID [0..=7].
payload_len_bits: u16Payload length in bits (not bytes).
Implementations§
Source§impl Header
impl Header
Sourcepub fn payload_len_bytes(&self) -> usize
pub fn payload_len_bytes(&self) -> usize
Compute payload length in bytes (ceil(bits / 8)).
Sourcepub fn total_bytes(&self) -> usize
pub fn total_bytes(&self) -> usize
Total packet size including header + payload + CRC-32 trailer, in bytes.
= 6 (header) + ceil(payload_len_bits / 8) (payload + padding) + 4 (CRC).
Sourcepub fn payload_bytes<'a>(&self, packet: &'a [u8]) -> Result<&'a [u8], Error>
pub fn payload_bytes<'a>(&self, packet: &'a [u8]) -> Result<&'a [u8], Error>
Slice the payload bytes out of the full packet buffer this header was
parsed from (the 6 header bytes, then payload_len_bytes() of payload,
then the 4-byte CRC trailer).
Errors with Error::PayloadLengthMismatch when the buffer is too
short for the declared payload_len_bits.
Trait Implementations§
impl Copy for Header
Source§impl<'de> Deserialize<'de> for Header
impl<'de> Deserialize<'de> for Header
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Header
Source§impl Serialize for Header
impl Serialize for Header
Source§type Error = Error
type Error = Error
The error type this implementer returns (usually the same as the
corresponding
Parse impl, but need not be).Source§fn serialized_len(&self) -> usize
fn serialized_len(&self) -> usize
Number of bytes
serialize_into will write.impl StructuralPartialEq for Header
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnsafeUnpin for Header
impl UnwindSafe for Header
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more