pub struct HeaderExtension {
pub little_endian: bool,
pub message_length: Option<u32>,
pub timestamp: Option<HeTimestamp>,
pub uextension4: Option<[u8; 4]>,
pub wextension8: Option<[u8; 8]>,
pub checksum: ChecksumValue,
pub parameters: Option<ParameterList>,
}Expand description
Parsed HeaderExtension submessage.
Fields§
§little_endian: boolEndianness of the body (true = little-endian).
message_length: Option<u32>If the L flag is set: remaining length of the message.
timestamp: Option<HeTimestamp>If the W flag is set: sender timestamp.
uextension4: Option<[u8; 4]>If the U flag is set: 4-byte vendor-specific value.
wextension8: Option<[u8; 8]>If the V flag is set: 16-byte vendor-specific value.
checksum: ChecksumValueIf the C flag != 0: checksum value.
parameters: Option<ParameterList>If the P flag is set: ParameterList.
Implementations§
Source§impl HeaderExtension
impl HeaderExtension
Sourcepub fn new() -> Self
pub fn new() -> Self
Empty HE (all optional fields absent). Manipulate the fields directly in builder style.
Sourcepub fn encode_body(&self) -> Result<Vec<u8>, WireError>
pub fn encode_body(&self) -> Result<Vec<u8>, WireError>
Encodes the body without the submessage header. The body length is
by construction ≤ MAX_HE_LENGTH.
Order: L → W → U → V → C → P, per Spec §9.4.5.2.
§Errors
ValueOutOfRange if the body would be > u16::MAX or
MAX_HE_LENGTH.
Sourcepub fn encode(&self) -> Result<Vec<u8>, WireError>
pub fn encode(&self) -> Result<Vec<u8>, WireError>
Encodes the HE as a complete submessage = 4-byte SubmessageHeader
- body.
octets_to_next_headeris set to the body length.
§Errors
ValueOutOfRange if the body length > u16::MAX.
Sourcepub fn decode_body(body: &[u8], flags: u8) -> Result<Self, WireError>
pub fn decode_body(body: &[u8], flags: u8) -> Result<Self, WireError>
Decodes the HE body from a slice of length
octets_to_next_header, given the flag byte from the
submessage header.
§Errors
UnexpectedEof, ValueOutOfRange (body larger than
MAX_HE_LENGTH).
Sourcepub fn decode(bytes: &[u8]) -> Result<Self, WireError>
pub fn decode(bytes: &[u8]) -> Result<Self, WireError>
Decodes a complete HE submessage (header + body) from
bytes. Checks the SubmessageId.
§Errors
UnexpectedEof, UnknownSubmessageId, ValueOutOfRange.
Sourcepub fn validate_message_length(
&self,
actual_message_length: u32,
) -> Result<(), WireError>
pub fn validate_message_length( &self, actual_message_length: u32, ) -> Result<(), WireError>
Cross-check: if message_length is set, it MUST equal the
actual remaining length of the RTPS message from the first
submessage header (i.e. from byte 20 = after the RtpsHeader) up to the
end of the datagram (Spec §8.3.7.4).
actual_message_length is the remaining length measured by the
receiver.
§Errors
ValueOutOfRange on mismatch.
Trait Implementations§
Source§impl Clone for HeaderExtension
impl Clone for HeaderExtension
Source§fn clone(&self) -> HeaderExtension
fn clone(&self) -> HeaderExtension
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more