pub struct ValueDescriptions { /* private fields */ }Expand description
Value descriptions for a signal.
Maps numeric signal values to human-readable text descriptions. For example, a gear position signal might map:
- 0 -> “Park”
- 1 -> “Reverse”
- 2 -> “Neutral”
- 3 -> “Drive”
§Examples
use dbc_rs::Dbc;
let dbc_content = r#"VERSION "1.0"
BU_: ECM
BO_ 100 EngineData : 8 ECM
SG_ GearPosition : 0|8@1+ (1,0) [0|5] "" *
VAL_ 100 GearPosition 0 "Park" 1 "Reverse" 2 "Neutral" 3 "Drive" ;
"#;
let dbc = Dbc::parse(dbc_content)?;
let message = dbc.messages().iter().find(|m| m.id() == 100).unwrap();
let signal = message.signals().find("GearPosition").unwrap();
if let Some(value_descriptions) = dbc.value_descriptions_for_signal(message.id(), signal.name()) {
if let Some(description) = value_descriptions.get(0) {
println!("Value 0 means: {}", description);
}
}Implementations§
Source§impl ValueDescriptions
impl ValueDescriptions
Sourcepub fn get(&self, value: u64) -> Option<&str>
pub fn get(&self, value: u64) -> Option<&str>
Get the description for a numeric value
§Examples
if let Some(value_descriptions) = dbc.value_descriptions_for_signal(message.id(), signal.name()) {
if let Some(desc) = value_descriptions.get(0) {
println!("Value 0: {}", desc);
}
}Sourcepub fn at(&self, index: usize) -> Option<(u64, &str)>
pub fn at(&self, index: usize) -> Option<(u64, &str)>
Get a value description by index.
Returns None if the index is out of bounds.
§Arguments
index- The zero-based index of the value description
§Examples
if let Some(value_descriptions) = dbc.value_descriptions_for_signal(message.id(), signal.name()) {
if let Some((value, description)) = value_descriptions.at(0) {
println!("Value {}: {}", value, description);
}
}Trait Implementations§
Source§impl Clone for ValueDescriptions
impl Clone for ValueDescriptions
Source§fn clone(&self) -> ValueDescriptions
fn clone(&self) -> ValueDescriptions
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ValueDescriptions
impl Debug for ValueDescriptions
Source§impl Hash for ValueDescriptions
impl Hash for ValueDescriptions
Source§impl PartialEq for ValueDescriptions
impl PartialEq for ValueDescriptions
impl Eq for ValueDescriptions
impl StructuralPartialEq for ValueDescriptions
Auto Trait Implementations§
impl Freeze for ValueDescriptions
impl RefUnwindSafe for ValueDescriptions
impl Send for ValueDescriptions
impl Sync for ValueDescriptions
impl Unpin for ValueDescriptions
impl UnwindSafe for ValueDescriptions
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)