pub struct FastDbc { /* private fields */ }Expand description
High-performance DBC wrapper with O(1) message lookup.
Wraps a Dbc and adds a HashMap index for fast message lookup by CAN ID.
Use this when you need to decode many frames at high speed.
Cloning is O(1) due to internal Arc usage.
Implementations§
Source§impl FastDbc
impl FastDbc
Sourcepub fn new(dbc: Dbc) -> Self
pub fn new(dbc: Dbc) -> Self
Create a new FastDbc wrapper from a Dbc.
This builds a HashMap index for O(1) message lookup.
Sourcepub fn get(&self, id: u32) -> Option<&Message>
pub fn get(&self, id: u32) -> Option<&Message>
Get a message by standard (11-bit) CAN ID.
Returns None if no message with this ID exists.
§Performance
O(1) average case.
Sourcepub fn get_extended(&self, id: u32) -> Option<&Message>
pub fn get_extended(&self, id: u32) -> Option<&Message>
Get a message by extended (29-bit) CAN ID.
Use this for extended CAN IDs.
Sourcepub fn get_any(&self, id: u32) -> Option<&Message>
pub fn get_any(&self, id: u32) -> Option<&Message>
Get a message by CAN ID, trying with extended flag if standard not found.
Single lookup optimization: checks if id exists, then tries with extended flag.
Sourcepub fn decode_into(
&self,
id: u32,
data: &[u8],
out: &mut [f64],
) -> Option<usize>
pub fn decode_into( &self, id: u32, data: &[u8], out: &mut [f64], ) -> Option<usize>
Decode a message by standard CAN ID into the output buffer.
This is the primary high-speed decode path:
- O(1) message lookup
- Zero allocation
- Direct buffer write
§Arguments
id- Standard (11-bit) CAN IDdata- Raw CAN payload bytesout- Output buffer for physical values
§Returns
Number of signals decoded, or None if message not found or payload too short.
Sourcepub fn decode_extended_into(
&self,
id: u32,
data: &[u8],
out: &mut [f64],
) -> Option<usize>
pub fn decode_extended_into( &self, id: u32, data: &[u8], out: &mut [f64], ) -> Option<usize>
Decode a message by extended CAN ID into the output buffer.
Sourcepub fn decode_raw_into(
&self,
id: u32,
data: &[u8],
out: &mut [i64],
) -> Option<usize>
pub fn decode_raw_into( &self, id: u32, data: &[u8], out: &mut [i64], ) -> Option<usize>
Decode raw values by standard CAN ID.
Sourcepub fn max_signals(&self) -> usize
pub fn max_signals(&self) -> usize
Get the maximum number of signals in any single message.
Use this to pre-allocate decode buffers.
Sourcepub fn total_signals(&self) -> usize
pub fn total_signals(&self) -> usize
Get the total number of signals across all messages.
Sourcepub fn message_count(&self) -> usize
pub fn message_count(&self) -> usize
Get the number of messages.
Sourcepub fn contains_extended(&self, id: u32) -> bool
pub fn contains_extended(&self, id: u32) -> bool
Check if a message with this extended CAN ID exists.