Skip to main content

Message

Trait Message 

Source
pub trait Message: Sized {
    // Required methods
    fn message_id(&self) -> u32;
    fn message_name(&self) -> &'static str;
    fn target_system_id(&self) -> Option<u8>;
    fn target_component_id(&self) -> Option<u8>;
    fn ser(&self, version: MavlinkVersion, bytes: &mut [u8]) -> usize;
    fn parse(
        version: MavlinkVersion,
        msgid: u32,
        payload: &[u8],
    ) -> Result<Self, ParserError>;
    fn message_id_from_name(name: &str) -> Option<u32>;
    fn default_message_from_id(id: u32) -> Option<Self>;
    fn random_message_from_id<R>(id: u32, rng: &mut R) -> Option<Self>
       where R: RngCore;
    fn extra_crc(id: u32) -> u8;
}
Expand description

A MAVLink message payload

Each message sets MavMessage enum implements this trait. The Message trait is used to represent messages in an abstract way (for example, common::MavMessage).

Required Methods§

Source

fn message_id(&self) -> u32

MAVLink message ID

Source

fn message_name(&self) -> &'static str

MAVLink message name

Source

fn target_system_id(&self) -> Option<u8>

Target system ID if the message is directed to a specific system

Source

fn target_component_id(&self) -> Option<u8>

Target component ID if the message is directed to a specific component

Source

fn ser(&self, version: MavlinkVersion, bytes: &mut [u8]) -> usize

Serialize Message into byte slice and return count of bytes written

§Panics

Will panic if the buffer provided is to small to store this message

Source

fn parse( version: MavlinkVersion, msgid: u32, payload: &[u8], ) -> Result<Self, ParserError>

Parse a Message from its message id and payload bytes

§Errors
  • UnknownMessage if the given message id is not part of the dialect
  • any other ParserError returned by the individual message deserialization
Source

fn message_id_from_name(name: &str) -> Option<u32>

Return message id of specific message name

Source

fn default_message_from_id(id: u32) -> Option<Self>

Return a default message of the speicfied message id

Source

fn random_message_from_id<R>(id: u32, rng: &mut R) -> Option<Self>
where R: RngCore,

Available on crate feature arbitrary only.

Return random valid message of the speicfied message id

Source

fn extra_crc(id: u32) -> u8

Return a message types CRC_EXTRA byte

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Message for mavlink::dialects::all::MavMessage

Available on crate feature dialect-all only.
Source§

impl Message for mavlink::dialects::ardupilotmega::MavMessage

Available on crate feature dialect-ardupilotmega only.
Source§

impl Message for mavlink::dialects::asluav::MavMessage

Available on crate feature dialect-asluav only.
Source§

impl Message for mavlink::dialects::avssuas::MavMessage

Available on crate feature dialect-avssuas only.
Source§

impl Message for mavlink::dialects::common::MavMessage

Available on crate feature dialect-common only.
Source§

impl Message for mavlink::dialects::csairlink::MavMessage

Available on crate feature dialect-csairlink only.
Source§

impl Message for mavlink::dialects::cubepilot::MavMessage

Available on crate feature dialect-cubepilot only.
Source§

impl Message for mavlink::dialects::development::MavMessage

Available on crate feature dialect-development only.
Source§

impl Message for mavlink::dialects::icarous::MavMessage

Available on crate feature dialect-icarous only.
Source§

impl Message for mavlink::dialects::loweheiser::MavMessage

Available on crate feature dialect-loweheiser only.
Source§

impl Message for mavlink::dialects::marsh::MavMessage

Available on crate feature dialect-marsh only.
Source§

impl Message for mavlink::dialects::matrixpilot::MavMessage

Available on crate feature dialect-matrixpilot only.
Source§

impl Message for mavlink::dialects::minimal::MavMessage

Available on crate feature dialect-minimal only.
Source§

impl Message for mavlink::dialects::paparazzi::MavMessage

Available on crate feature dialect-paparazzi only.
Source§

impl Message for mavlink::dialects::python_array_test::MavMessage

Available on crate feature dialect-python_array_test only.
Source§

impl Message for mavlink::dialects::standard::MavMessage

Available on crate feature dialect-standard only.
Source§

impl Message for mavlink::dialects::stemstudios::MavMessage

Available on crate feature dialect-stemstudios only.
Source§

impl Message for mavlink::dialects::storm32::MavMessage

Available on crate feature dialect-storm32 only.
Source§

impl Message for mavlink::dialects::test::MavMessage

Available on crate feature dialect-test only.
Source§

impl Message for mavlink::dialects::ualberta::MavMessage

Available on crate feature dialect-ualberta only.
Source§

impl Message for mavlink::dialects::uavionix::MavMessage

Available on crate feature dialect-uavionix only.