pub struct Signals { /* private fields */ }Expand description
Encapsulates the signals array for a message
Uses Vec<Signal> for dynamic sizing.
Implementations§
Source§impl Signals
impl Signals
Sourcepub fn iter(&self) -> impl Iterator<Item = &Signal> + '_
pub fn iter(&self) -> impl Iterator<Item = &Signal> + '_
Get an iterator over the signals
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse("VERSION \"1.0\"\n\nBU_: ECM\n\nBO_ 256 Engine : 8 ECM\n SG_ RPM : 0|16@1+ (0.25,0) [0|8000] \"rpm\"")?;
let message = dbc.messages().at(0).unwrap();
for signal in message.signals().iter() {
println!("Signal: {} (start: {}, length: {})", signal.name(), signal.start_bit(), signal.length());
}Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the number of signals
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse("VERSION \"1.0\"\n\nBU_: ECM\n\nBO_ 256 Engine : 8 ECM\n SG_ RPM : 0|16@1+ (0.25,0) [0|8000] \"rpm\"")?;
let message = dbc.messages().at(0).unwrap();
assert_eq!(message.signals().len(), 1);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if there are no signals
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse("VERSION \"1.0\"\n\nBU_: ECM\n\nBO_ 256 Engine : 8 ECM")?;
let message = dbc.messages().at(0).unwrap();
assert!(message.signals().is_empty());Sourcepub fn at(&self, index: usize) -> Option<&Signal>
pub fn at(&self, index: usize) -> Option<&Signal>
Get a signal by index, or None if index is out of bounds
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse("VERSION \"1.0\"\n\nBU_: ECM\n\nBO_ 256 Engine : 8 ECM\n SG_ RPM : 0|16@1+ (0.25,0) [0|8000] \"rpm\"")?;
let message = dbc.messages().at(0).unwrap();
if let Some(signal) = message.signals().at(0) {
assert_eq!(signal.name(), "RPM");
}Sourcepub fn find(&self, name: &str) -> Option<&Signal>
pub fn find(&self, name: &str) -> Option<&Signal>
Find a signal by name, or None if not found
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse("VERSION \"1.0\"\n\nBU_: ECM\n\nBO_ 256 Engine : 8 ECM\n SG_ RPM : 0|16@1+ (0.25,0) [0|8000] \"rpm\"")?;
let message = dbc.messages().at(0).unwrap();
if let Some(signal) = message.signals().find("RPM") {
assert_eq!(signal.name(), "RPM");
assert_eq!(signal.factor(), 0.25);
}Trait Implementations§
impl Eq for Signals
impl StructuralPartialEq for Signals
Auto Trait Implementations§
impl Freeze for Signals
impl RefUnwindSafe for Signals
impl Send for Signals
impl Sync for Signals
impl Unpin for Signals
impl UnwindSafe for Signals
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)