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
.
§Links
Implementations§
source§impl<V: MaybeVersioned> Header<V>
impl<V: MaybeVersioned> Header<V>
sourcepub fn version(&self) -> MavLinkVersion
pub fn version(&self) -> MavLinkVersion
sourcepub fn payload_length(&self) -> PayloadLength
pub fn payload_length(&self) -> PayloadLength
Payload length.
Indicates length of the following payload
section. This may be affected by payload truncation.
sourcepub fn sequence(&self) -> Sequence
pub fn sequence(&self) -> Sequence
Packet sequence number.
Used to detect packet loss. Components increment value for each message sent.
sourcepub fn system_id(&self) -> SystemId
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.
sourcepub fn component_id(&self) -> ComponentId
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.
sourcepub fn message_id(&self) -> MessageId
pub fn message_id(&self) -> MessageId
Message ID
.
ID
of MAVLink message. Defines how payload will be encoded and decoded.
sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Size of the header in bytes.
Depends on the MAVLink protocol version.
sourcepub fn is_signed(&self) -> bool
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
).
§Links
sourcepub fn body_length(&self) -> usize
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).
§Links
sourcepub fn decode(&self) -> HeaderBytes
pub fn decode(&self) -> HeaderBytes
Decodes Header
as HeaderBytes
.
Returns header data encoded as a sequence of bytes.
sourcepub fn try_into_versioned<Version: MaybeVersioned>(
self,
) -> Result<Header<Version>, VersionError>
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.
sourcepub fn try_to_versioned<Version: MaybeVersioned>(
&self,
) -> Result<Header<Version>, VersionError>
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.
sourcepub fn into_versionless(self) -> Header<Versionless>
pub fn into_versionless(self) -> Header<Versionless>
Forget about header’s version transforming it into a Versionless
variant.
sourcepub fn to_versionless(&self) -> Header<Versionless>
pub fn to_versionless(&self) -> Header<Versionless>
Create a Versionless
header from the existing one.
source§impl Header<V2>
impl Header<V2>
sourcepub fn incompat_flags(&self) -> IncompatFlags
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).
sourcepub fn compat_flags(&self) -> CompatFlags
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).
source§impl Header<Versionless>
impl Header<Versionless>
sourcepub fn builder() -> HeaderBuilder<Versionless, Unset, Unset, Unset, Unset, Unset>
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
.
sourcepub fn incompat_flags(&self) -> Option<IncompatFlags>
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).
sourcepub fn compat_flags(&self) -> Option<CompatFlags>
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).
Trait Implementations§
source§impl<'de, V: MaybeVersioned> Deserialize<'de> for Header<V>
impl<'de, V: MaybeVersioned> Deserialize<'de> for Header<V>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<V: MaybeVersioned> Serialize for Header<V>
impl<V: MaybeVersioned> Serialize for Header<V>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)