Struct mavio::Endpoint

source ·
pub struct Endpoint<V: MaybeVersioned> { /* private fields */ }
Expand description

MAVLink device with defined ID and internal frame sequence counter.

§Examples

use mavio::dialects::minimal::messages::Heartbeat;
use mavio::prelude::*;

// Create a `MAVLink2` device with system and component ids
let device = Endpoint::v2(MavLinkId::new(17, 42));
device.advance(3).discard();

// Build a new frame from the provided message
let frame = device.next_frame(&Heartbeat::default()).unwrap();

assert_eq!(frame.sequence(), 3, "should be correct sequence number");
assert_eq!(frame.system_id(), 17, "should be the defined system `ID`");
assert_eq!(frame.component_id(), 42, "should be the defined component `ID`");

Implementations§

source§

impl Endpoint<Versionless>

source

pub fn new<V: MaybeVersioned>(id: MavLinkId) -> Endpoint<V>

Creates a new device with specified MavLinkId.

source

pub fn v1(id: MavLinkId) -> Endpoint<V1>

Creates a MAVLink1 device with specified MavLinkId.

source

pub fn v2(id: MavLinkId) -> Endpoint<V2>

Creates a MAVLink2 device with specified MavLinkId.

source

pub fn versionless(id: MavLinkId) -> Endpoint<Versionless>

Creates a device without a specified MAVLink protocol version.

source

pub fn next_frame<V: Versioned>( &self, message: &dyn Message ) -> Result<Frame<Versionless>>

Produces a next versionless frame from MAVLink message.

The actual protocol version still has to be specified as a generic parameter using turbofish syntax.

source§

impl<V: MaybeVersioned> Endpoint<V>

source

pub fn id(&self) -> MavLinkId

Device ID.

source

pub fn system_id(&self) -> SystemId

MAVLink system ID.

source

pub fn component_id(&self) -> ComponentId

MAVLink component ID.

source

pub fn next_sequence(&self) -> Sequence

Next MAVLink frame sequence.

source

pub fn sequencer(&self) -> &Sequencer

Returns a reference to internal Sequencer.

source

pub fn advance(&self, increment: Sequence) -> Behold<Sequence>

Skips increment items in sequence and return the updated current value.

The return value is wrapped in Behold since it is not guaranteed in multithreaded environments, that the Endpoint::next_frame will use the same value of a sequence in this thread.

source

pub fn fork(&self) -> Self

Forks existing endpoint.

Forking is similar to cloning, except the internal frame Sequencer will be forked to start from the next value. This method is available for all targets, while cloning is possible only for alloc targets.

See Sequencer::fork for details.

source

pub fn sync<Version: MaybeVersioned>(&self, other: &Endpoint<Version>)

Synchronizes this endpoint with another one.

Synchronizes internal sequencer with the sequencer of the other Endpoint.

See Sequencer::sync for details.

source

pub fn join<Version: MaybeVersioned>(&self, other: &mut Endpoint<Version>)

alloc Joins another endpoint with current one.

From this moment internal sequencers will share the same counter. The current sequencer will be synced with the one it joins.

Available only when alloc feature is enabled.

See Sequencer::join for details.

source§

impl<V: Versioned> Endpoint<V>

source

pub fn next_frame(&self, message: &dyn Message) -> Result<Frame<V>>

Produces a next frame from MAVLink message.

Trait Implementations§

source§

impl<V: MaybeVersioned> Clone for Endpoint<V>

source§

fn clone(&self) -> Self

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<V: Debug + MaybeVersioned> Debug for Endpoint<V>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<V> Freeze for Endpoint<V>

§

impl<V> RefUnwindSafe for Endpoint<V>
where V: RefUnwindSafe,

§

impl<V> Send for Endpoint<V>

§

impl<V> Sync for Endpoint<V>

§

impl<V> Unpin for Endpoint<V>
where V: Unpin,

§

impl<V> UnwindSafe for Endpoint<V>
where 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.