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§
Sourcefn message_id(&self) -> u32
fn message_id(&self) -> u32
MAVLink message ID
Sourcefn message_name(&self) -> &'static str
fn message_name(&self) -> &'static str
MAVLink message name
Sourcefn target_system_id(&self) -> Option<u8>
fn target_system_id(&self) -> Option<u8>
Target system ID if the message is directed to a specific system
Sourcefn target_component_id(&self) -> Option<u8>
fn target_component_id(&self) -> Option<u8>
Target component ID if the message is directed to a specific component
Sourcefn ser(&self, version: MavlinkVersion, bytes: &mut [u8]) -> usize
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
Sourcefn parse(
version: MavlinkVersion,
msgid: u32,
payload: &[u8],
) -> Result<Self, ParserError>
fn parse( version: MavlinkVersion, msgid: u32, payload: &[u8], ) -> Result<Self, ParserError>
Parse a Message from its message id and payload bytes
§Errors
UnknownMessageif the given message id is not part of the dialect- any other
ParserErrorreturned by the individual message deserialization
Sourcefn message_id_from_name(name: &str) -> Option<u32>
fn message_id_from_name(name: &str) -> Option<u32>
Return message id of specific message name
Sourcefn default_message_from_id(id: u32) -> Option<Self>
fn default_message_from_id(id: u32) -> Option<Self>
Return a default message of the speicfied message id
Sourcefn random_message_from_id<R>(id: u32, rng: &mut R) -> Option<Self>where
R: RngCore,
Available on crate feature arbitrary only.
fn random_message_from_id<R>(id: u32, rng: &mut R) -> Option<Self>where
R: RngCore,
arbitrary only.Return random valid message of the speicfied message id
Sourcefn extra_crc(id: u32) -> u8
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§
impl Message for mavlink::dialects::all::MavMessage
dialect-all only.impl Message for mavlink::dialects::ardupilotmega::MavMessage
dialect-ardupilotmega only.impl Message for mavlink::dialects::asluav::MavMessage
dialect-asluav only.impl Message for mavlink::dialects::avssuas::MavMessage
dialect-avssuas only.impl Message for mavlink::dialects::common::MavMessage
dialect-common only.impl Message for mavlink::dialects::csairlink::MavMessage
dialect-csairlink only.impl Message for mavlink::dialects::cubepilot::MavMessage
dialect-cubepilot only.impl Message for mavlink::dialects::development::MavMessage
dialect-development only.impl Message for mavlink::dialects::icarous::MavMessage
dialect-icarous only.impl Message for mavlink::dialects::loweheiser::MavMessage
dialect-loweheiser only.impl Message for mavlink::dialects::marsh::MavMessage
dialect-marsh only.impl Message for mavlink::dialects::matrixpilot::MavMessage
dialect-matrixpilot only.impl Message for mavlink::dialects::minimal::MavMessage
dialect-minimal only.impl Message for mavlink::dialects::paparazzi::MavMessage
dialect-paparazzi only.impl Message for mavlink::dialects::python_array_test::MavMessage
dialect-python_array_test only.impl Message for mavlink::dialects::standard::MavMessage
dialect-standard only.impl Message for mavlink::dialects::stemstudios::MavMessage
dialect-stemstudios only.impl Message for mavlink::dialects::storm32::MavMessage
dialect-storm32 only.impl Message for mavlink::dialects::test::MavMessage
dialect-test only.impl Message for mavlink::dialects::ualberta::MavMessage
dialect-ualberta only.impl Message for mavlink::dialects::uavionix::MavMessage
dialect-uavionix only.