pub struct Message<'a> { /* private fields */ }Expand description
Represents a CAN message in a DBC file.
A Message contains:
- A unique ID (CAN identifier)
- A name
- A DLC (Data Length Code) specifying the message size in bytes
- A sender node (ECU that transmits this message)
- A collection of signals
§Examples
use dbc_rs::Dbc;
let dbc_content = r#"VERSION "1.0"
BU_: ECM
BO_ 256 EngineData : 8 ECM
SG_ RPM : 0|16@0+ (0.25,0) [0|8000] "rpm" *
"#;
let dbc = Dbc::parse(dbc_content)?;
let message = dbc.messages().at(0).unwrap();
println!("Message: {} (ID: {})", message.name(), message.id());Implementations§
Source§impl<'a> Message<'a>
impl<'a> Message<'a>
Sourcepub fn id(&self) -> u32
pub fn id(&self) -> u32
Returns the CAN message ID.
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse(r#"VERSION "1.0"\n\nBU_: ECM\n\nBO_ 256 EngineData : 8 ECM"#)?;
let message = dbc.messages().at(0).unwrap();
assert_eq!(message.id(), 256);Sourcepub fn name(&self) -> &'a str
pub fn name(&self) -> &'a str
Returns the message name.
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse(r#"VERSION "1.0"\n\nBU_: ECM\n\nBO_ 256 EngineData : 8 ECM"#)?;
let message = dbc.messages().at(0).unwrap();
assert_eq!(message.name(), "EngineData");Sourcepub fn dlc(&self) -> u8
pub fn dlc(&self) -> u8
Returns the Data Length Code (DLC) in bytes.
DLC specifies the size of the message payload. For classic CAN, this is 1-8 bytes. For CAN FD, this can be up to 64 bytes.
§Examples
use dbc_rs::Dbc;
let dbc = Dbc::parse(r#"VERSION "1.0"\n\nBU_: ECM\n\nBO_ 256 EngineData : 8 ECM"#)?;
let message = dbc.messages().at(0).unwrap();
assert_eq!(message.dlc(), 8);pub fn sender(&self) -> &'a str
pub fn to_dbc_string(&self) -> String
pub fn to_dbc_string_with_signals(&self) -> String
Trait Implementations§
impl<'a> Eq for Message<'a>
impl<'a> StructuralPartialEq for Message<'a>
Auto Trait Implementations§
impl<'a> Freeze for Message<'a>
impl<'a> RefUnwindSafe for Message<'a>
impl<'a> Send for Message<'a>
impl<'a> Sync for Message<'a>
impl<'a> Unpin for Message<'a>
impl<'a> UnwindSafe for Message<'a>
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