Struct mavio::AsyncReceiver

source ·
pub struct AsyncReceiver<R: AsyncRead + Unpin, V: MaybeVersioned> { /* private fields */ }
Expand description

Receives MAVLink frames asynchronously.

Receives MAVLink frames from an instance of AsyncRead.

Implementations§

source§

impl<R: AsyncRead + Unpin> AsyncReceiver<R, Versionless>

source

pub fn new<V: MaybeVersioned>(reader: R) -> AsyncReceiver<R, V>

Default constructor.

source

pub fn versionless(reader: R) -> AsyncReceiver<R, Versionless>

Create a MAVLink version agnostic receiver.

Creates a protocol-agnostic receiver which will look up for both MAVLink 1 and MAVLink 2 frames.

If you want a receiver restricted to a specific MAVLink protocol version, use AsyncReceiver::versioned.

If you want to instantiate a generic receiver, use AsyncReceiver::new.

source

pub fn versioned<Version: Versioned>( reader: R, version: Version ) -> AsyncReceiver<R, Version>

Create a receiver specific to a particular MAVLink protocol version.

Same as AsyncReceiver::new::<V1> / AsyncReceiver::new::<V2> but with an explicit version marker as a parameter.

Since versioned receiver will look up for MAVLink frames starting with a specific MavSTX magic byte, it may behave incorrectly, if the incoming stream contains frames of a different protocol version. If this is the case, it is preferred to construct versionless receiver by AsyncReceiver::new and then attempt to convert incoming frames into a specific protocol version with Frame::try_into_versioned.

source§

impl<R: AsyncRead + Unpin, V: MaybeVersioned> AsyncReceiver<R, V>

source

pub async fn recv(&mut self) -> Result<Frame<V>>

Receives MAVLink Frame.

Blocks until a valid MAVLink frame received.

Versioned receiver accepts only frames of a specific MAVLink protocol version.

Versionless receiver accepts both MAVLink 1 and MAVLink 2 frames.

Trait Implementations§

source§

impl<R: Clone + AsyncRead + Unpin, V: Clone + MaybeVersioned> Clone for AsyncReceiver<R, V>

source§

fn clone(&self) -> AsyncReceiver<R, V>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<R: Debug + AsyncRead + Unpin, V: Debug + MaybeVersioned> Debug for AsyncReceiver<R, V>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R, V> Freeze for AsyncReceiver<R, V>
where R: Freeze,

§

impl<R, V> RefUnwindSafe for AsyncReceiver<R, V>

§

impl<R, V> Send for AsyncReceiver<R, V>
where R: Send,

§

impl<R, V> Sync for AsyncReceiver<R, V>
where R: Sync,

§

impl<R, V> Unpin for AsyncReceiver<R, V>
where V: Unpin,

§

impl<R, V> UnwindSafe for AsyncReceiver<R, V>
where R: UnwindSafe, V: 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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.