pub struct AsyncMavlinkReader<R> { /* private fields */ }tokio, or crate feature embedded and non-crate feature std only.Expand description
Incrementally reads complete MAVLink frames from an asynchronous byte stream.
Partial input remains buffered if a read is cancelled. Use the same MAVLink
dialect M for the lifetime of a stream, because CRC validation is
dialect-specific.
Implementations§
Source§impl<R> AsyncMavlinkReader<R>
impl<R> AsyncMavlinkReader<R>
Sourcepub fn new(source: R) -> Selfwhere
R: AsyncRead + Unpin,
Available on crate feature std only.
pub fn new(source: R) -> Selfwhere
R: AsyncRead + Unpin,
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) -> Selfwhere
R: AsyncRead + Unpin,
Available on crate feature std only.
pub fn with_capacity(capacity: usize, source: R) -> Selfwhere
R: AsyncRead + Unpin,
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: AsyncRead + Unpin> AsyncMavlinkReader<R>
impl<R: AsyncRead + Unpin> AsyncMavlinkReader<R>
Sourcepub async fn read_message<M: Message>(
&mut self,
version: MavlinkVersion,
) -> Result<(MavHeader, M), MessageReadError>
Available on crate feature tokio only.
pub async fn read_message<M: Message>( &mut self, version: MavlinkVersion, ) -> Result<(MavHeader, M), MessageReadError>
tokio only.Reads and parses the next CRC-valid message accepted by version.
Sourcepub async fn read_message_with_dialect<D: Dialect>(
&mut self,
dialect: &D,
version: MavlinkVersion,
) -> Result<(MavHeader, D::Message), MessageReadError>
Available on crate feature tokio only.
pub async fn read_message_with_dialect<D: Dialect>( &mut self, dialect: &D, version: MavlinkVersion, ) -> Result<(MavHeader, D::Message), MessageReadError>
tokio only.Like Self::read_message, using dialect for CRC validation and decoding.
Sourcepub async fn read_any_message<M: Message>(
&mut self,
) -> Result<(MavHeader, M), MessageReadError>
Available on crate feature tokio only.
pub async fn read_any_message<M: Message>( &mut self, ) -> Result<(MavHeader, M), MessageReadError>
tokio only.Reads and parses the next CRC-valid MAVLink 1 or MAVLink 2 message.
Sourcepub async fn read_any_message_with_dialect<D: Dialect>(
&mut self,
dialect: &D,
) -> Result<(MavHeader, D::Message), MessageReadError>
Available on crate feature tokio only.
pub async fn read_any_message_with_dialect<D: Dialect>( &mut self, dialect: &D, ) -> Result<(MavHeader, D::Message), MessageReadError>
tokio only.Like Self::read_any_message, using dialect for CRC validation and decoding.
Sourcepub async fn read_raw_message<M: Message>(
&mut self,
version: MavlinkVersion,
) -> Result<MAVLinkMessageRaw, MessageReadError>
Available on crate feature tokio only.
pub async fn read_raw_message<M: Message>( &mut self, version: MavlinkVersion, ) -> Result<MAVLinkMessageRaw, MessageReadError>
tokio only.Reads the next CRC-valid raw message accepted by version.
Sourcepub async fn read_raw_message_with_dialect<D: Dialect>(
&mut self,
dialect: &D,
version: MavlinkVersion,
) -> Result<MAVLinkMessageRaw, MessageReadError>
Available on crate feature tokio only.
pub async fn read_raw_message_with_dialect<D: Dialect>( &mut self, dialect: &D, version: MavlinkVersion, ) -> Result<MAVLinkMessageRaw, MessageReadError>
tokio only.Like Self::read_raw_message, using dialect for CRC validation and decoding.
Sourcepub async fn read_any_raw_message<M: Message>(
&mut self,
) -> Result<MAVLinkMessageRaw, MessageReadError>
Available on crate feature tokio only.
pub async fn read_any_raw_message<M: Message>( &mut self, ) -> Result<MAVLinkMessageRaw, MessageReadError>
tokio only.Reads the next CRC-valid MAVLink 1 or MAVLink 2 raw message.
Sourcepub async fn read_any_raw_message_with_dialect<D: Dialect>(
&mut self,
dialect: &D,
) -> Result<MAVLinkMessageRaw, MessageReadError>
Available on crate feature tokio only.
pub async fn read_any_raw_message_with_dialect<D: Dialect>( &mut self, dialect: &D, ) -> Result<MAVLinkMessageRaw, MessageReadError>
tokio only.Like Self::read_any_raw_message, using dialect for CRC validation and decoding.
Sourcepub async fn read_message_signed<M: Message>(
&mut self,
version: MavlinkVersion,
signing_data: Option<&SigningData>,
) -> Result<(MavHeader, M), MessageReadError>
Available on crate features mav2-message-signing and tokio only.
pub async fn read_message_signed<M: Message>( &mut self, version: MavlinkVersion, signing_data: Option<&SigningData>, ) -> Result<(MavHeader, M), MessageReadError>
mav2-message-signing and tokio 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 async fn read_message_signed_with_dialect<D: Dialect>(
&mut self,
dialect: &D,
version: MavlinkVersion,
signing_data: Option<&SigningData>,
) -> Result<(MavHeader, D::Message), MessageReadError>
Available on crate features mav2-message-signing and tokio only.
pub async fn read_message_signed_with_dialect<D: Dialect>( &mut self, dialect: &D, version: MavlinkVersion, signing_data: Option<&SigningData>, ) -> Result<(MavHeader, D::Message), MessageReadError>
mav2-message-signing and tokio only.Like Self::read_message_signed, using dialect for CRC validation and decoding.
Sourcepub async fn read_any_message_signed<M: Message>(
&mut self,
signing_data: Option<&SigningData>,
) -> Result<(MavHeader, M), MessageReadError>
Available on crate features mav2-message-signing and tokio only.
pub async fn read_any_message_signed<M: Message>( &mut self, signing_data: Option<&SigningData>, ) -> Result<(MavHeader, M), MessageReadError>
mav2-message-signing and tokio 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 async fn read_any_message_signed_with_dialect<D: Dialect>(
&mut self,
dialect: &D,
signing_data: Option<&SigningData>,
) -> Result<(MavHeader, D::Message), MessageReadError>
Available on crate features mav2-message-signing and tokio only.
pub async fn read_any_message_signed_with_dialect<D: Dialect>( &mut self, dialect: &D, signing_data: Option<&SigningData>, ) -> Result<(MavHeader, D::Message), MessageReadError>
mav2-message-signing and tokio only.Like Self::read_any_message_signed, using dialect for CRC validation and decoding.
Sourcepub async fn read_raw_message_signed<M: Message>(
&mut self,
version: MavlinkVersion,
signing_data: Option<&SigningData>,
) -> Result<MAVLinkMessageRaw, MessageReadError>
Available on crate features mav2-message-signing and tokio only.
pub async fn read_raw_message_signed<M: Message>( &mut self, version: MavlinkVersion, signing_data: Option<&SigningData>, ) -> Result<MAVLinkMessageRaw, MessageReadError>
mav2-message-signing and tokio 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 async fn read_raw_message_signed_with_dialect<D: Dialect>(
&mut self,
dialect: &D,
version: MavlinkVersion,
signing_data: Option<&SigningData>,
) -> Result<MAVLinkMessageRaw, MessageReadError>
Available on crate features mav2-message-signing and tokio only.
pub async fn read_raw_message_signed_with_dialect<D: Dialect>( &mut self, dialect: &D, version: MavlinkVersion, signing_data: Option<&SigningData>, ) -> Result<MAVLinkMessageRaw, MessageReadError>
mav2-message-signing and tokio only.Like Self::read_raw_message_signed, using dialect for CRC validation and decoding.
Sourcepub async fn read_any_raw_message_signed<M: Message>(
&mut self,
signing_data: Option<&SigningData>,
) -> Result<MAVLinkMessageRaw, MessageReadError>
Available on crate features mav2-message-signing and tokio only.
pub async fn read_any_raw_message_signed<M: Message>( &mut self, signing_data: Option<&SigningData>, ) -> Result<MAVLinkMessageRaw, MessageReadError>
mav2-message-signing and tokio 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.
Sourcepub async fn read_any_raw_message_signed_with_dialect<D: Dialect>(
&mut self,
dialect: &D,
signing_data: Option<&SigningData>,
) -> Result<MAVLinkMessageRaw, MessageReadError>
Available on crate features mav2-message-signing and tokio only.
pub async fn read_any_raw_message_signed_with_dialect<D: Dialect>( &mut self, dialect: &D, signing_data: Option<&SigningData>, ) -> Result<MAVLinkMessageRaw, MessageReadError>
mav2-message-signing and tokio only.Like Self::read_any_raw_message_signed, using dialect for CRC validation and decoding.