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
impl BuildHelper
sourcepub fn builder<T>(out_path: T) -> BuildHelperBuilder
pub fn builder<T>(out_path: T) -> BuildHelperBuilder
Creates configuration builder for BuildHelper
.
Takes out_path
as argument. The output path for generated content.
sourcepub fn generate(&self) -> Result<(), RustGenError>
pub fn generate(&self) -> Result<(), RustGenError>
Scans for dialects and generates MAVLink dialects.
sourcepub fn manifest_path(&self) -> Option<&Path>
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
:
Self::microservices
frommicroservices
key.Self::messages
frommessages
key.Self::enums
fromenums
key.Self::commands
fromcommands
key.Self::generate_tests
fromgenerate_tests
key.
Note that if set explicitly, these parameters has precedence over keys from manifest.
sourcepub fn include_dialects(&self) -> Option<HashSet<&str>>
pub fn include_dialects(&self) -> Option<HashSet<&str>>
Included dialects.
sourcepub fn exclude_dialects(&self) -> Option<HashSet<&str>>
pub fn exclude_dialects(&self) -> Option<HashSet<&str>>
Excluded dialects.
sourcepub fn messages(&self) -> Option<Vec<&str>>
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.
sourcepub fn enums(&self) -> Option<Vec<&str>>
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.
sourcepub fn commands(&self) -> Option<Vec<&str>>
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.
sourcepub fn microservices(&self) -> Option<&Microservices>
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.
sourcepub fn generate_tests(&self) -> bool
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
impl Clone for BuildHelper
source§fn clone(&self) -> BuildHelper
fn clone(&self) -> BuildHelper
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more