pub struct EnumDescriptor {
pub name: &'static str,
pub bitmask: bool,
pub entries: &'static [EnumEntry],
}Expand description
A dialect enumeration: its name, whether its values combine as bits, and every value it names, in the order the dialect lists them.
Fields§
§name: &'static strThe enumeration’s name, such as "MAV_STATE".
bitmask: boolWhether a field of this enumeration holds several of its values at once, one per bit.
entries: &'static [EnumEntry]Every value the enumeration names.
Implementations§
Source§impl EnumDescriptor
impl EnumDescriptor
Sourcepub fn value(&self, entry: &str) -> Option<u64>
pub fn value(&self, entry: &str) -> Option<u64>
Returns the value an entry of this enumeration names.
§Arguments
entry- the entry’s name as the dialect writes it, such as"MAV_STATE_STANDBY".
§Returns
Some(value), or None if no entry of this enumeration has that name.
§Examples
use pamoja_mavlink::dialect::enum_named;
let state = enum_named("MAV_STATE").expect("a dialect enumeration");
assert_eq!(state.value("MAV_STATE_STANDBY"), Some(3));Sourcepub fn names(&self, value: u64) -> impl Iterator<Item = &'static str> + '_
pub fn names(&self, value: u64) -> impl Iterator<Item = &'static str> + '_
Returns the names a value is made of.
§Arguments
value- the value a field carried.
§Returns
For a bitmask, each entry whose bits are all set in value, in dialect order, or the
entry for zero when value is zero. Otherwise the one entry that names value. Bits
or values no entry names are left out.
§Examples
use pamoja_mavlink::dialect::{enum_named, mav_mode_flag};
let flags = enum_named("MAV_MODE_FLAG").expect("a dialect enumeration");
let base_mode = mav_mode_flag::SAFETY_ARMED | mav_mode_flag::CUSTOM_MODE_ENABLED;
let names: Vec<&str> = flags.names(u64::from(base_mode)).collect();
assert_eq!(names, ["MAV_MODE_FLAG_SAFETY_ARMED", "MAV_MODE_FLAG_CUSTOM_MODE_ENABLED"]);Trait Implementations§
Source§impl Clone for EnumDescriptor
impl Clone for EnumDescriptor
Source§fn clone(&self) -> EnumDescriptor
fn clone(&self) -> EnumDescriptor
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for EnumDescriptor
Source§impl Debug for EnumDescriptor
impl Debug for EnumDescriptor
impl Eq for EnumDescriptor
Source§impl PartialEq for EnumDescriptor
impl PartialEq for EnumDescriptor
impl StructuralPartialEq for EnumDescriptor
Auto Trait Implementations§
impl Freeze for EnumDescriptor
impl RefUnwindSafe for EnumDescriptor
impl Send for EnumDescriptor
impl Sync for EnumDescriptor
impl Unpin for EnumDescriptor
impl UnsafeUnpin for EnumDescriptor
impl UnwindSafe for EnumDescriptor
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