Skip to main content

AsyncMavlinkReader

Struct AsyncMavlinkReader 

Source
pub struct AsyncMavlinkReader<R> { /* private fields */ }
Available on crate feature 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>

Source

pub fn new(source: R) -> AsyncMavlinkReader<R>
where R: AsyncRead + Unpin,

Available on crate feature 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.

Source

pub fn with_capacity(capacity: usize, source: R) -> AsyncMavlinkReader<R>
where R: AsyncRead + Unpin,

Available on crate feature 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.

Source

pub const fn get_ref(&self) -> &R

Returns a shared reference to the underlying source.

Source

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.

Source

pub fn into_inner(self) -> R

Returns the underlying source.

Any bytes read ahead by this reader are discarded.

Source§

impl<R> AsyncMavlinkReader<R>
where R: AsyncRead + Unpin,

Source

pub async fn read_message<M>( &mut self, version: MavlinkVersion, ) -> Result<(MavHeader, M), MessageReadError>
where M: Message,

Available on crate feature tokio only.

Reads and parses the next CRC-valid message accepted by version.

Source

pub async fn read_any_message<M>( &mut self, ) -> Result<(MavHeader, M), MessageReadError>
where M: Message,

Available on crate feature tokio only.

Reads and parses the next CRC-valid MAVLink 1 or MAVLink 2 message.

Source

pub async fn read_raw_message<M>( &mut self, version: MavlinkVersion, ) -> Result<MAVLinkMessageRaw, MessageReadError>
where M: Message,

Available on crate feature tokio only.

Reads the next CRC-valid raw message accepted by version.

Source

pub async fn read_any_raw_message<M>( &mut self, ) -> Result<MAVLinkMessageRaw, MessageReadError>
where M: Message,

Available on crate feature tokio only.

Reads the next CRC-valid MAVLink 1 or MAVLink 2 raw message.

Source

pub async fn read_message_signed<M>( &mut self, version: MavlinkVersion, signing_data: Option<&SigningData>, ) -> Result<(MavHeader, M), MessageReadError>
where M: Message,

Available on crate features 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.

Source

pub async fn read_any_message_signed<M>( &mut self, signing_data: Option<&SigningData>, ) -> Result<(MavHeader, M), MessageReadError>
where M: Message,

Available on crate features 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.

Source

pub async fn read_raw_message_signed<M>( &mut self, version: MavlinkVersion, signing_data: Option<&SigningData>, ) -> Result<MAVLinkMessageRaw, MessageReadError>
where M: Message,

Available on crate features 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.

Source

pub async fn read_any_raw_message_signed<M>( &mut self, signing_data: Option<&SigningData>, ) -> Result<MAVLinkMessageRaw, MessageReadError>
where M: Message,

Available on crate features 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.

Auto Trait Implementations§

§

impl<R> Freeze for AsyncMavlinkReader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for AsyncMavlinkReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for AsyncMavlinkReader<R>
where R: Send,

§

impl<R> Sync for AsyncMavlinkReader<R>
where R: Sync,

§

impl<R> Unpin for AsyncMavlinkReader<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for AsyncMavlinkReader<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for AsyncMavlinkReader<R>
where R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.