Struct mavio::protocol::Header

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

MAVLink frame header.

Header contains information relevant to for MAVLink 1 and MAVLink 2 packet formats.

§Versioned and versionless headers

In most cases, you are going to receive a Versionless header. However, if you want to work in a context of a specific MAVLink protocol version, you can convert header into a Versioned variant by calling Header::try_into_versioned.

You always can forget about header’s version by calling Header::into_versionless.

Implementations§

source§

impl<V: MaybeVersioned> Header<V>

source

pub fn version(&self) -> MavLinkVersion

MAVLink protocol version.

MAVLink version defined by the magic byte (STX).

See MavSTX.

source

pub fn payload_length(&self) -> PayloadLength

Payload length.

Indicates length of the following payload section. This may be affected by payload truncation.

source

pub fn sequence(&self) -> Sequence

Packet sequence number.

Used to detect packet loss. Components increment value for each message sent.

source

pub fn system_id(&self) -> SystemId

System ID.

ID of system (vehicle) sending the message. Used to differentiate systems on network.

Note that the broadcast address 0 may not be used in this field as it is an invalid source address.

source

pub fn component_id(&self) -> ComponentId

Component ID.

ID of component sending the message. Used to differentiate components in a system (e.g. autopilot and a camera). Use appropriate values in MAV_COMPONENT.

Note that the broadcast address MAV_COMP_ID_ALL may not be used in this field as it is an invalid source address.

source

pub fn message_id(&self) -> MessageId

Message ID.

ID of MAVLink message. Defines how payload will be encoded and decoded.

source

pub fn size(&self) -> usize

Size of the header in bytes.

Depends on the MAVLink protocol version.

source

pub fn is_signed(&self) -> bool

Returns true if frame body should contain signature.

For MAVLink 1 headers always returns false.

For MAVLink 2 it checks for IncompatFlags::MAVLINK_IFLAG_SIGNED (default is false).

source

pub fn body_length(&self) -> usize

MAVLink frame body length.

Calculates expected size in bytes for frame body. Depends on MAVLink protocol version and presence of signature (when IncompatFlags::MAVLINK_IFLAG_SIGNED incompatibility flag is set).

source

pub fn decode(&self) -> HeaderBytes

Decodes Header as HeaderBytes.

Returns header data encoded as a sequence of bytes.

source

pub fn try_into_versioned<Version: MaybeVersioned>( self ) -> Result<Header<Version>, VersionError>

Attempts to transform existing header into its versioned form.

This method never changes the internal MAVLink protocol version. It will return an error, if conversion is not possible.

source

pub fn try_to_versioned<Version: MaybeVersioned>( &self ) -> Result<Header<Version>, VersionError>

Attempts to create header with specified version from existing one.

This method never changes the internal MAVLink protocol version. It will return an error, if conversion is not possible.

source

pub fn into_versionless(self) -> Header<Versionless>

Forget about header’s version transforming it into a Versionless variant.

source

pub fn to_versionless(&self) -> Header<Versionless>

Create a Versionless header from the existing one.

source§

impl Header<V2>

source

pub fn incompat_flags(&self) -> IncompatFlags

Incompatibility flags for MAVLink 2 header.

Flags that must be understood for MAVLink compatibility (implementation discards packet if it does not understand flag).

See: MAVLink 2 incompatibility flags.

source

pub fn compat_flags(&self) -> CompatFlags

Compatibility flags for MAVLink 2 header.

Flags that can be ignored if not understood (implementation can still handle packet even if it does not understand flag).

See: MAVLink 2 compatibility flags.

source§

impl Header<Versionless>

source

pub fn builder( ) -> HeaderBuilder<Versionless, Unset, Unset, Unset, Unset, Unset>

Initiates builder for Header.

Instead of constructor we use builder pattern. An instance of HeaderBuilder returned by this function is initialized with default values. Once desired values are set, you can call HeaderBuilder::build to obtain Header.

source

pub fn incompat_flags(&self) -> Option<IncompatFlags>

Incompatibility flags for MAVLink 2 header.

Flags that must be understood for MAVLink compatibility (implementation discards packet if it does not understand flag).

See: MAVLink 2 incompatibility flags.

source

pub fn compat_flags(&self) -> Option<CompatFlags>

Compatibility flags for MAVLink 2 header.

Flags that can be ignored if not understood (implementation can still handle packet even if it does not understand flag).

See: MAVLink 2 compatibility flags.

Trait Implementations§

source§

impl<V: Clone + MaybeVersioned> Clone for Header<V>

source§

fn clone(&self) -> Header<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<V: Debug + MaybeVersioned> Debug for Header<V>

source§

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

Formats the value using the given formatter. Read more
source§

impl<V: Default + MaybeVersioned> Default for Header<V>

source§

fn default() -> Header<V>

Returns the “default value” for a type. Read more
source§

impl<'de, V: MaybeVersioned> Deserialize<'de> for Header<V>

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<V: MaybeVersioned> Serialize for Header<V>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<V: Copy + MaybeVersioned> Copy for Header<V>

Auto Trait Implementations§

§

impl<V> Freeze for Header<V>

§

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

§

impl<V> Send for Header<V>

§

impl<V> Sync for Header<V>

§

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

§

impl<V> UnwindSafe for Header<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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,