pub struct MessageDescriptor<'a> {
pub id: u32,
pub name: &'a str,
pub crc_extra: u8,
pub fields: &'a [FieldDescriptor<'a>],
}Expand description
The shape of one message: what a sender fills in and a receiver reads back.
Fields are held in wire order, which for the base fields is largest type first. A
descriptor written by hand must already be in that order;
MessageDescriptorBuilder does the reordering for a definition written the way a
dialect reads.
Fields§
§id: u32The message id on the wire.
name: &'a strThe message name, such as "HEARTBEAT".
crc_extra: u8The CRC_EXTRA seed folded into the checksum of a frame carrying this message.
fields: &'a [FieldDescriptor<'a>]The fields in wire order: the base fields largest first, then any extensions.
Implementations§
Source§impl<'a> MessageDescriptor<'a>
impl<'a> MessageDescriptor<'a>
Sourcepub fn wire_len(&self) -> usize
pub fn wire_len(&self) -> usize
Returns the full length of the message on the wire, extensions included.
§Returns
The sum of every field’s size, in bytes.
Sourcepub fn base_len(&self) -> usize
pub fn base_len(&self) -> usize
Returns the length of the message’s base fields, in bytes.
This is what a peer that predates the extensions expects, and the length the
CRC_EXTRA seed describes.
§Returns
The sum of the base fields’ sizes.
Sourcepub fn field(&self, name: &str) -> Option<&'a FieldDescriptor<'a>>
pub fn field(&self, name: &str) -> Option<&'a FieldDescriptor<'a>>
Sourcepub fn derived_crc_extra(&self) -> u8
pub fn derived_crc_extra(&self) -> u8
Derives the CRC_EXTRA seed from this descriptor’s base fields.
A descriptor whose crc_extra differs from this has a field
wrong: a mistyped field, a wrong array length, or fields out of wire order.
§Returns
The seed the fields imply.
§Examples
use pamoja_mavlink::dialect::descriptor;
let heartbeat = descriptor(0).expect("HEARTBEAT is in the common dialect");
assert_eq!(heartbeat.derived_crc_extra(), heartbeat.crc_extra);Trait Implementations§
Source§impl<'a> Clone for MessageDescriptor<'a>
impl<'a> Clone for MessageDescriptor<'a>
Source§fn clone(&self) -> MessageDescriptor<'a>
fn clone(&self) -> MessageDescriptor<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'a> Copy for MessageDescriptor<'a>
Source§impl<'a> Debug for MessageDescriptor<'a>
impl<'a> Debug for MessageDescriptor<'a>
impl<'a> Eq for MessageDescriptor<'a>
Source§impl<'a> PartialEq for MessageDescriptor<'a>
impl<'a> PartialEq for MessageDescriptor<'a>
Source§fn eq(&self, other: &MessageDescriptor<'a>) -> bool
fn eq(&self, other: &MessageDescriptor<'a>) -> bool
self and other values to be equal, and is used by ==.