Skip to main content

MessageDescriptorBuilder

Struct MessageDescriptorBuilder 

Source
pub struct MessageDescriptorBuilder { /* private fields */ }
Expand description

Builds a message shape from a definition written the way a dialect reads.

Fields are given in declaration order. MAVLink puts the base fields on the wire largest type first, keeping equal-sized fields in the order declared, and leaves extension fields at the end untouched; build applies that and derives the CRC_EXTRA seed from the result, so a transcription error surfaces as a checksum a peer rejects rather than as silently misread fields.

Implementations§

Source§

impl MessageDescriptorBuilder

Source

pub fn new(id: u32, name: impl Into<String>) -> Self

Starts a shape for a message id and name.

§Arguments
  • id - the message id on the wire.
  • name - the message name, which the CRC_EXTRA derivation folds in, so it must match the dialect exactly.
§Returns

The builder, with no fields yet.

Source

pub fn field( self, name: impl Into<String>, ty: FieldType, array_len: u8, ) -> Self

Adds a base field, in the order the definition declares it.

§Arguments
  • name - the field name.
  • ty - the field’s scalar type, or an array’s element type.
  • array_len - the element count for an array, or 0 for a scalar.
§Returns

The builder.

Source

pub fn extension( self, name: impl Into<String>, ty: FieldType, array_len: u8, ) -> Self

Adds a MAVLink 2 extension field, in the order the definition declares it.

Extensions keep their declared order, are excluded from the CRC_EXTRA seed, and read as zero from a frame sent by a peer that predates them.

§Arguments
  • name - the field name.
  • ty - the field’s scalar type, or an array’s element type.
  • array_len - the element count for an array, or 0 for a scalar.
§Returns

The builder.

Source

pub fn build(self) -> Result<OwnedMessageDescriptor>

Puts the fields in wire order and derives the seed.

§Returns

The finished shape.

§Errors

Returns MavlinkError::DuplicateField if two fields share a name, and MavlinkError::PayloadTooLong if the fields do not fit a MAVLink payload.

Trait Implementations§

Source§

impl Clone for MessageDescriptorBuilder

Source§

fn clone(&self) -> MessageDescriptorBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MessageDescriptorBuilder

Source§

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

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

impl Default for MessageDescriptorBuilder

Source§

fn default() -> MessageDescriptorBuilder

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

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,

Source§

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.