pub struct Command { /* private fields */ }
Expand description
MAVLink command.
§Usage
Commands can be created only from the corresponding EnumEntry
.
use mavinspect::protocol::{Command, EnumEntry, EnumEntryMavCmdParam};
use mavinspect::utils::{Buildable, Builder};
let cmd_entry = EnumEntry::builder()
.set_name("CMD_CUSTOM")
.set_params(vec![
EnumEntryMavCmdParam::builder()
.set_index(1)
.set_description("first")
.build(),
/* create remaining parameters in the same fashion */
])
.build();
let command = Command::from(cmd_entry);
assert_eq!(
command.params().iter().map(|param| param.description()).collect::<Vec<_>>(),
vec!["first", "second", "third", "fourth", "fifth", "sixth", "seventh"]
);
Implementations§
Source§impl Command
impl Command
Sourcepub fn from_enum_entry(enum_entry: &EnumEntry) -> Self
pub fn from_enum_entry(enum_entry: &EnumEntry) -> Self
Sourcepub fn value(&self) -> MavCmdValue
pub fn value(&self) -> MavCmdValue
Enum entry value.
Sourcepub fn name_stripped(&self) -> &str
pub fn name_stripped(&self) -> &str
Command name without the corresponding enum name prefix.
See EnumEntry::name_stripped
for stripping logic details.
Sourcepub fn description(&self) -> &str
pub fn description(&self) -> &str
Enum entry description.
Sourcepub fn has_location(&self) -> bool
pub fn has_location(&self) -> bool
Has location.
See EnumEntryMavCmdFlags::has_location
for details.
Sourcepub fn is_destination(&self) -> bool
pub fn is_destination(&self) -> bool
Is destination.
See EnumEntryMavCmdFlags::is_destination
for details.
Sourcepub fn mission_only(&self) -> bool
pub fn mission_only(&self) -> bool
Mission only.
See EnumEntryMavCmdFlags::mission_only
for details.
Sourcepub fn params(&self) -> &[EnumEntryMavCmdParam]
pub fn params(&self) -> &[EnumEntryMavCmdParam]
Enum entry MAV_CMD
parameters.
Sourcepub fn deprecated(&self) -> Option<&Deprecated>
pub fn deprecated(&self) -> Option<&Deprecated>
Deprecation status.
Sourcepub fn defined_in(&self) -> &str
pub fn defined_in(&self) -> &str
Dialect name where this command was defined.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Command
impl<'de> Deserialize<'de> for Command
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl NamedType for Command
impl NamedType for Command
fn sid() -> SpectaID
Source§fn named_data_type(
type_map: &mut TypeCollection,
generics: &[DataType],
) -> NamedDataType
fn named_data_type( type_map: &mut TypeCollection, generics: &[DataType], ) -> NamedDataType
this is equivalent to Type::inline but returns a NamedDataType instead.
Source§fn definition_named_data_type(type_map: &mut TypeCollection) -> NamedDataType
fn definition_named_data_type(type_map: &mut TypeCollection) -> NamedDataType
this is equivalent to [Type::definition] but returns a NamedDataType instead.
Source§impl Type for Command
impl Type for Command
Source§fn inline(type_map: &mut TypeCollection, generics: Generics<'_>) -> DataType
fn inline(type_map: &mut TypeCollection, generics: Generics<'_>) -> DataType
Returns the definition of a type using the provided generics. Read more
Source§fn reference(type_map: &mut TypeCollection, generics: &[DataType]) -> Reference
fn reference(type_map: &mut TypeCollection, generics: &[DataType]) -> Reference
Generates a datatype corresponding to a reference to this type,
as determined by its category. Getting a reference to a type implies that
it should belong in the type map (since it has to be referenced from somewhere),
so the output of
definition
will be put into the type map.impl Flatten for Command
Auto Trait Implementations§
impl Freeze for Command
impl RefUnwindSafe for Command
impl Send for Command
impl Sync for Command
impl Unpin for Command
impl UnwindSafe for Command
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
Mutably borrows from an owned value. Read more