Struct mavio::AsyncSender

source ·
pub struct AsyncSender<W: AsyncWrite + Unpin, V: MaybeVersioned> { /* private fields */ }
Expand description

Sends MAVLink frames asynchronously.

Sends MAVLink frames to an instance of AsyncWrite.

Implementations§

source§

impl<W: AsyncWrite + Unpin> AsyncSender<W, Versionless>

source

pub fn new<V: MaybeVersioned>(writer: W) -> AsyncSender<W, V>

Default constructor.

source

pub fn versionless(writer: W) -> Self

Create a MAVLink version agnostic sender.

Creates a protocol-agnostic sender which can send both MAVLink 1 and MAVLink 2 frames.

If you want a sender that sends only frames restricted to a particular MAVLink protocol version, use AsyncSender::versioned.

If you want to instantiate a generic sender, use AsyncSender::new.

source

pub fn versioned<Version: Versioned>( writer: W, version: Version ) -> AsyncSender<W, Version>

Create a receiver specific to a particular MAVLink protocol version.

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

If you want to send both MAVLink 1 and MAVLink 2 frames, use AsyncSender::versionless.

source§

impl<W: AsyncWrite + Unpin, V: MaybeVersioned> AsyncSender<W, V>

source

pub async fn send(&mut self, frame: &Frame<V>) -> Result<usize>

Send MAVLink Frame asynchronously.

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

Versionless sender accepts both MAVLink 1 and MAVLink 2 frames as Frame<Versionless>.

Returns the number of bytes sent.

source

pub async fn flush(&mut self) -> Result<()>

Flushes all buffers.

Certain writers require flush to be called on tear down in order to write all contents.

Trait Implementations§

source§

impl<W: Clone + AsyncWrite + Unpin, V: Clone + MaybeVersioned> Clone for AsyncSender<W, V>

source§

fn clone(&self) -> AsyncSender<W, 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<W: Debug + AsyncWrite + Unpin, V: Debug + MaybeVersioned> Debug for AsyncSender<W, V>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<W, V> Freeze for AsyncSender<W, V>
where W: Freeze,

§

impl<W, V> RefUnwindSafe for AsyncSender<W, V>

§

impl<W, V> Send for AsyncSender<W, V>
where W: Send,

§

impl<W, V> Sync for AsyncSender<W, V>
where W: Sync,

§

impl<W, V> Unpin for AsyncSender<W, V>
where V: Unpin,

§

impl<W, V> UnwindSafe for AsyncSender<W, V>
where V: UnwindSafe, W: 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.