Skip to main content

HeaderExtension

Struct HeaderExtension 

Source
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: bool

Endianness 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: ChecksumValue

If the C flag != 0: checksum value.

§parameters: Option<ParameterList>

If the P flag is set: ParameterList.

Implementations§

Source§

impl HeaderExtension

Source

pub fn new() -> Self

Empty HE (all optional fields absent). Manipulate the fields directly in builder style.

Source

pub fn flag_byte(&self) -> u8

Computes the flag byte (incl. E bit) from the set fields.

Source

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.

Source

pub fn encode(&self) -> Result<Vec<u8>, WireError>

Encodes the HE as a complete submessage = 4-byte SubmessageHeader

  • body. octets_to_next_header is set to the body length.
§Errors

ValueOutOfRange if the body length > u16::MAX.

Source

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

Source

pub fn decode(bytes: &[u8]) -> Result<Self, WireError>

Decodes a complete HE submessage (header + body) from bytes. Checks the SubmessageId.

§Errors

UnexpectedEof, UnknownSubmessageId, ValueOutOfRange.

Source

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

Source§

fn clone(&self) -> HeaderExtension

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HeaderExtension

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HeaderExtension

Source§

fn default() -> HeaderExtension

Returns the “default value” for a type. Read more
Source§

impl Eq for HeaderExtension

Source§

impl PartialEq for HeaderExtension

Source§

fn eq(&self, other: &HeaderExtension) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for HeaderExtension

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.