dbc_rs/message/mod.rs
1mod core;
2mod parse;
3#[cfg(feature = "std")]
4mod serialize;
5mod signals;
6mod validate;
7
8#[cfg(feature = "std")]
9mod builder;
10
11use crate::{MAX_NAME_SIZE, compat::String};
12#[cfg(feature = "std")]
13pub use builder::MessageBuilder;
14pub use signals::Signals;
15
16/// Represents a CAN message in a DBC file.
17///
18/// A `Message` contains:
19/// - A unique ID (CAN identifier)
20/// - A name
21/// - A DLC (Data Length Code) specifying the message size in bytes
22/// - A sender node (ECU that transmits this message)
23/// - A collection of signals
24///
25/// # Examples
26///
27/// ```rust,no_run
28/// use dbc_rs::Dbc;
29///
30/// let dbc_content = r#"VERSION "1.0"
31///
32/// BU_: ECM
33///
34/// BO_ 256 EngineData : 8 ECM
35/// SG_ RPM : 0|16@0+ (0.25,0) [0|8000] "rpm" *
36/// "#;
37///
38/// let dbc = Dbc::parse(dbc_content)?;
39/// let message = dbc.messages().at(0).unwrap();
40/// println!("Message: {} (ID: {})", message.name(), message.id());
41/// # Ok::<(), dbc_rs::Error>(())
42/// ```
43#[derive(Debug, Clone, PartialEq, Eq, Hash)]
44pub struct Message {
45 id: u32,
46 name: String<{ MAX_NAME_SIZE }>,
47 dlc: u8,
48 sender: String<{ MAX_NAME_SIZE }>,
49 signals: Signals,
50}