pub struct MavlinkReader<R> { /* private fields */ }Expand description
Incrementally reads complete MAVLink frames from a blocking byte stream.
The reader keeps partial and read-ahead data between calls. Use the same
MAVLink dialect M for the lifetime of a stream, because CRC validation is
dialect-specific.
Implementations§
Source§impl<R> MavlinkReader<R>
impl<R> MavlinkReader<R>
Sourcepub fn new(source: R) -> MavlinkReader<R>where
R: Read,
Available on crate feature std only.
pub fn new(source: R) -> MavlinkReader<R>where
R: Read,
std only.Creates a reader around source with the default read-ahead capacity.
The buffer is allocated once and reused for the reader’s lifetime.
Sourcepub fn with_capacity(capacity: usize, source: R) -> MavlinkReader<R>where
R: Read,
Available on crate feature std only.
pub fn with_capacity(capacity: usize, source: R) -> MavlinkReader<R>where
R: Read,
std only.Creates a reader with at least capacity bytes of read-ahead space.
Capacities smaller than one maximum-size MAVLink frame are raised to
consts::MAX_FRAME_SIZE. The buffer is
allocated once and reused for the lifetime of the reader.
Sourcepub const fn get_mut(&mut self) -> &mut R
pub const fn get_mut(&mut self) -> &mut R
Returns a mutable reference to the underlying source.
Reading directly from the source can skip bytes already buffered by this reader and should therefore be avoided.
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Returns the underlying source.
Any bytes read ahead by this reader are discarded.
Source§impl<R> MavlinkReader<R>where
R: Read,
impl<R> MavlinkReader<R>where
R: Read,
Sourcepub fn read_message<M>(
&mut self,
version: MavlinkVersion,
) -> Result<(MavHeader, M), MessageReadError>where
M: Message,
Available on crate feature std, or crate feature embedded and non-crate feature std only.
pub fn read_message<M>(
&mut self,
version: MavlinkVersion,
) -> Result<(MavHeader, M), MessageReadError>where
M: Message,
std, or crate feature embedded and non-crate feature std only.Reads and parses the next CRC-valid message accepted by version.
Sourcepub fn read_any_message<M>(
&mut self,
) -> Result<(MavHeader, M), MessageReadError>where
M: Message,
Available on crate feature std, or crate feature embedded and non-crate feature std only.
pub fn read_any_message<M>(
&mut self,
) -> Result<(MavHeader, M), MessageReadError>where
M: Message,
std, or crate feature embedded and non-crate feature std only.Reads and parses the next CRC-valid MAVLink 1 or MAVLink 2 message.
Sourcepub fn read_raw_message<M>(
&mut self,
version: MavlinkVersion,
) -> Result<MAVLinkMessageRaw, MessageReadError>where
M: Message,
Available on crate feature std, or crate feature embedded and non-crate feature std only.
pub fn read_raw_message<M>(
&mut self,
version: MavlinkVersion,
) -> Result<MAVLinkMessageRaw, MessageReadError>where
M: Message,
std, or crate feature embedded and non-crate feature std only.Reads the next CRC-valid raw message accepted by version.
Sourcepub fn read_any_raw_message<M>(
&mut self,
) -> Result<MAVLinkMessageRaw, MessageReadError>where
M: Message,
Available on crate feature std, or crate feature embedded and non-crate feature std only.
pub fn read_any_raw_message<M>(
&mut self,
) -> Result<MAVLinkMessageRaw, MessageReadError>where
M: Message,
std, or crate feature embedded and non-crate feature std only.Reads the next CRC-valid MAVLink 1 or MAVLink 2 raw message.
Sourcepub fn read_message_signed<M>(
&mut self,
version: MavlinkVersion,
signing_data: Option<&SigningData>,
) -> Result<(MavHeader, M), MessageReadError>where
M: Message,
Available on crate feature mav2-message-signing and (crate feature std, or crate feature embedded and non-crate feature std) only.
pub fn read_message_signed<M>(
&mut self,
version: MavlinkVersion,
signing_data: Option<&SigningData>,
) -> Result<(MavHeader, M), MessageReadError>where
M: Message,
mav2-message-signing and (crate feature std, or crate feature embedded and non-crate feature std) only.Reads, verifies, and parses the next message accepted by version.
With signing data, MAVLink 1 and unsigned MAVLink 2 frames require
SigningConfig::allow_unsigned; signed MAVLink 2 frames must have a valid
signature. With None, signature verification is skipped.
Sourcepub fn read_any_message_signed<M>(
&mut self,
signing_data: Option<&SigningData>,
) -> Result<(MavHeader, M), MessageReadError>where
M: Message,
Available on crate feature mav2-message-signing and (crate feature std, or crate feature embedded and non-crate feature std) only.
pub fn read_any_message_signed<M>(
&mut self,
signing_data: Option<&SigningData>,
) -> Result<(MavHeader, M), MessageReadError>where
M: Message,
mav2-message-signing and (crate feature std, or crate feature embedded and non-crate feature std) only.Reads, verifies, and parses the next MAVLink 1 or MAVLink 2 message.
With signing data, MAVLink 1 frames follow SigningConfig::allow_unsigned.
With None, signature verification is skipped.
Sourcepub fn read_raw_message_signed<M>(
&mut self,
version: MavlinkVersion,
signing_data: Option<&SigningData>,
) -> Result<MAVLinkMessageRaw, MessageReadError>where
M: Message,
Available on crate feature mav2-message-signing and (crate feature std, or crate feature embedded and non-crate feature std) only.
pub fn read_raw_message_signed<M>(
&mut self,
version: MavlinkVersion,
signing_data: Option<&SigningData>,
) -> Result<MAVLinkMessageRaw, MessageReadError>where
M: Message,
mav2-message-signing and (crate feature std, or crate feature embedded and non-crate feature std) only.Reads and verifies the next raw message accepted by version.
With signing data, MAVLink 1 and unsigned MAVLink 2 frames require
SigningConfig::allow_unsigned; signed MAVLink 2 frames must have a valid
signature. With None, signature verification is skipped.
Sourcepub fn read_any_raw_message_signed<M>(
&mut self,
signing_data: Option<&SigningData>,
) -> Result<MAVLinkMessageRaw, MessageReadError>where
M: Message,
Available on crate feature mav2-message-signing and (crate feature std, or crate feature embedded and non-crate feature std) only.
pub fn read_any_raw_message_signed<M>(
&mut self,
signing_data: Option<&SigningData>,
) -> Result<MAVLinkMessageRaw, MessageReadError>where
M: Message,
mav2-message-signing and (crate feature std, or crate feature embedded and non-crate feature std) only.Reads and verifies the next MAVLink 1 or MAVLink 2 raw message.
With signing data, MAVLink 1 frames follow SigningConfig::allow_unsigned.
With None, signature verification is skipped.