pub trait Message: Sized {
const ID: u32;
const NAME: &'static str;
const CRC_EXTRA: u8;
const WIRE_LEN: usize;
const BASE_FIELDS: &'static [(&'static str, &'static str, u8)];
const DESCRIPTOR: &'static MessageDescriptor<'static>;
// Required methods
fn encode(&self, out: &mut [u8]) -> usize;
fn decode(payload: &[u8]) -> Result<Self>;
}Expand description
A typed MAVLink message: its identity on the wire and how it serializes.
Implemented for every message this crate types, via the message! declaration macro.
Required Associated Constants§
Sourceconst CRC_EXTRA: u8
const CRC_EXTRA: u8
The CRC_EXTRA seed folded into the checksum of a frame carrying this message.
Sourceconst BASE_FIELDS: &'static [(&'static str, &'static str, u8)]
const BASE_FIELDS: &'static [(&'static str, &'static str, u8)]
The base fields in wire order as (type, name, array_len), the input from which
CRC_EXTRA is derived and against which it is verified.
Sourceconst DESCRIPTOR: &'static MessageDescriptor<'static>
const DESCRIPTOR: &'static MessageDescriptor<'static>
The message’s shape as data: the runtime counterpart of this type’s fields, for a caller reading and writing by name rather than through the struct.
Required Methods§
Sourcefn encode(&self, out: &mut [u8]) -> usize
fn encode(&self, out: &mut [u8]) -> usize
Serializes the message into out, returning the number of bytes written.
§Arguments
out- the destination buffer, which must be at leastWIRE_LENbytes; aMAX_PAYLOAD-byte buffer always suffices.
§Returns
The number of bytes written, which is WIRE_LEN.
Sourcefn decode(payload: &[u8]) -> Result<Self>
fn decode(payload: &[u8]) -> Result<Self>
Deserializes the message from a payload.
A short payload is zero-extended, as MAVLink 2 truncation requires, and a payload
longer than WIRE_LEN (one carrying extension fields) has its
trailing bytes ignored.
§Arguments
payload- the frame payload to read.
§Returns
The decoded message.
§Errors
Returns MavlinkError::BadPayload if the
payload cannot form the message.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".