pub struct Message {
pub header: Header,
pub submessages: Vec<Submessage>,
}Expand description
A whole RTPS message, as carried in one UDP datagram (9.5).
Fields§
§header: HeaderThe header.
submessages: Vec<Submessage>The submessages, in order.
Implementations§
Source§impl Message
impl Message
Sourcepub fn decode(bytes: &[u8]) -> Result<Message, DecodeError>
pub fn decode(bytes: &[u8]) -> Result<Message, DecodeError>
Reads a whole message and fails on the first problem.
The receive rules of 8.3.4.1 say that the submessages before an
invalid one are still valid. To act on those, use
Message::parse instead.
Sourcepub fn parse(bytes: &[u8]) -> Result<(Header, Submessages<'_>), DecodeError>
pub fn parse(bytes: &[u8]) -> Result<(Header, Submessages<'_>), DecodeError>
Reads the header and returns an iterator over the submessages.
The iterator follows 8.3.4.1: unknown submessage ids and unknown
flags are skipped (unknown ids come out as
Submessage::Unknown), and after the first error it yields that
error and then stops, as the rest of the message is invalid.
Like Message::parse, with the payloads of DATA and DATA_FRAG
as slices of bytes instead of copies.
Sourcepub fn encode(&self, endianness: Endianness) -> Result<Vec<u8>, EncodeError>
pub fn encode(&self, endianness: Endianness) -> Result<Vec<u8>, EncodeError>
Writes the message with every submessage in byte order
endianness.
Each submessage but the last is padded with zeros so that the next
one starts on a 4-octet boundary (9.4.1). The last one may be
longer than 65535 octets; its octetsToNextHeader is then 0
(9.4.5.1.3).
Sourcepub fn encode_into(
&self,
out: &mut Vec<u8>,
endianness: Endianness,
) -> Result<(), EncodeError>
pub fn encode_into( &self, out: &mut Vec<u8>, endianness: Endianness, ) -> Result<(), EncodeError>
Like Message::encode, appending to out.