Struct mavspec::rust::gen::BuildHelper

source ·
pub struct BuildHelper { /* private fields */ }
Expand description

Code builder for Rust generator.

§Usage

use mavinspect::protocol::Microservices;
use mavspec::rust::gen::BuildHelper;

// Paths to XML definitions directories.
let sources = vec![
    "./message_definitions/standard",
    "./message_definitions/extra",
];
// Output path
let destination = "../tmp/mavlink";

// Generate rust bindings
BuildHelper::builder(destination)
    .set_sources(&sources)
    // Only include the following dialects
    .set_include_dialects(&["minimal", "common", "ardupilotmega"])
    // Explicitly exclude the following dialects
    .set_exclude_dialects(&["ardupilotmega"])
    // Include only entities from the following MAVLink microservices
    .set_microservices(&["HEARTBEAT", "COMMAND"])
    // Explicitly add messages
    .set_messages(&["PROTOCOL_VERSION"])
    .generate()
    .unwrap();

Implementations§

source§

impl BuildHelper

source

pub fn builder<T>(out_path: T) -> BuildHelperBuilder
where T: Into<PathBuf>,

Creates configuration builder for BuildHelper.

Takes out_path as argument. The output path for generated content.

source

pub fn generate(&self) -> Result<(), RustGenError>

Scans for dialects and generates MAVLink dialects.

source

pub fn out_path(&self) -> &Path

Output path for autogenerated files.

source

pub fn sources(&self) -> Option<Vec<&Path>>

List of directories with MAVLink XML definitions.

source

pub fn manifest_path(&self) -> Option<&Path>

Path to Cargo.toml from which meta information will be extracted.

You can specify configuration in your Cargo.toml file:

[package.metadata.mavspec]
microservices = ["HEARTBEAT", "MISSION", "COMMAND"]
messages = ["PROTOCOL_VERSION", "MAV_INSPECT_V1", "PING"]
enums = ["STORAGE_STATUS", "GIMBAL_*"]
commands = ["MAV_CMD_DO_CHANGE_SPEED", "MAV_CMD_DO_SET_ROI*"]
generate_tests = false

If Self::manifest_path is set, then the following parameters will be populated from keys in Cargo.toml:

Note that if set explicitly, these parameters has precedence over keys from manifest.

source

pub fn include_dialects(&self) -> Option<HashSet<&str>>

Included dialects.

source

pub fn exclude_dialects(&self) -> Option<HashSet<&str>>

Excluded dialects.

source

pub fn messages(&self) -> Option<Vec<&str>>

If set, then defines the list of MAVLink messages to generate.

If Self::microservices are set, then the messages will be included in addition to those defined by microservices specifications.

source

pub fn enums(&self) -> Option<Vec<&str>>

If set, then defines the list of MAVLink enums to generate.

If Self::microservices are set, then the enums will be included in addition to those defined by microservices specifications.

source

pub fn commands(&self) -> Option<Vec<&str>>

If set, then defines the list of MAVLink commands to generate.

If Self::microservices are set, then the commands will be included in addition to those defined by microservices specifications.

source

pub fn microservices(&self) -> Option<&Microservices>

If set, then defines MAVLink microservices to be generated.

All messages from Self::messages will be included regardless of microservices specifications.

source

pub fn protocol(&self) -> Option<&Protocol>

MAVLink protocol containing parsed dialects.

source

pub fn serde(&self) -> bool

Serde support flag for generated entities.

source

pub fn generate_tests(&self) -> bool

Tests generation flag.

If set to true, then tests will be generated.

Trait Implementations§

source§

impl Clone for BuildHelper

source§

fn clone(&self) -> BuildHelper

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 Debug for BuildHelper

source§

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

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

impl Default for BuildHelper

source§

fn default() -> BuildHelper

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