pub struct MavFrame<M: Message> {
pub header: MavHeader,
pub msg: M,
pub protocol_version: MavlinkVersion,
}
Expand description
Encapsulation of the MAVLink message and the header, important to preserve information about the sender system and component id.
Fields§
§header: MavHeader
Message header data
msg: M
Parsed Message
payload
protocol_version: MavlinkVersion
Messages MAVLink version
Implementations§
Source§impl<M: Message> MavFrame<M>
impl<M: Message> MavFrame<M>
Sourcepub fn ser(&self, buf: &mut [u8]) -> usize
pub fn ser(&self, buf: &mut [u8]) -> usize
Serialize MavFrame into a byte slice, so it can be sent over a socket, for example. The resulting buffer will start with the sequence field of the MAVLink frame and will not include the initial packet marker, length field, and flags.
§Panics
Will panic if frame does not fit in the provided buffer.
Sourcepub fn deser(version: MavlinkVersion, input: &[u8]) -> Result<Self, ParserError>
pub fn deser(version: MavlinkVersion, input: &[u8]) -> Result<Self, ParserError>
Deserialize MavFrame from a slice that has been received from, for example, a socket. The input buffer should start with the sequence field of the MAVLink frame. The initial packet marker, length field, and flag fields should be excluded.
§Panics
Will panic if the buffer provided does not contain a full message
§Errors
Will return a ParserError
if a message was found but could not be parsed