FastDbc

Struct FastDbc 

Source
pub struct FastDbc { /* private fields */ }
Expand description

High-performance DBC wrapper with optimized message lookup and decoding.

§Performance Optimizations

  • Direct array lookup: Standard CAN IDs (0-2047) use direct array indexing
  • Pre-computed decode plans: All bit positions, masks, and flags computed at build time
  • Identity transform detection: Skips factor/offset math when factor=1, offset=0
  • Cache-friendly layout: Decode parameters packed for optimal cache usage
  • FxHash for extended IDs: Fast hash function for non-standard IDs

Cloning is O(1) due to internal Arc usage.

Implementations§

Source§

impl FastDbc

Source

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self>

Load a DBC file from disk and wrap it for fast access.

Source

pub fn new(dbc: Dbc) -> Self

Create a new FastDbc wrapper from a Dbc.

This pre-computes all decode parameters for maximum runtime performance.

Source

pub fn get(&self, id: u32) -> Option<&Message>

Get a message by standard (11-bit) CAN ID.

Source

pub fn get_extended(&self, id: u32) -> Option<&Message>

Get a message by extended (29-bit) CAN ID.

Source

pub fn get_any(&self, id: u32) -> Option<&Message>

Get a message by CAN ID, trying extended if standard not found.

Source

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 via direct array indexing
  • Pre-computed decode parameters
  • Identity transform detection (skips math when factor=1, offset=0)
  • Zero allocation
§Arguments
  • id - Standard (11-bit) CAN ID
  • data - Raw CAN payload bytes
  • out - Output buffer for physical values
§Returns

Number of signals decoded, or None if message not found or payload too short.

Source

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.

Source

pub fn decode_raw_into( &self, id: u32, data: &[u8], out: &mut [i64], ) -> Option<usize>

Decode raw values by standard CAN ID.

Source

pub fn max_signals(&self) -> usize

Get the maximum number of signals in any single message.

Use this to pre-allocate decode buffers.

Source

pub fn total_signals(&self) -> usize

Get the total number of signals across all messages.

Source

pub fn message_count(&self) -> usize

Get the number of messages.

Source

pub fn contains(&self, id: u32) -> bool

Check if a message with this standard CAN ID exists.

Source

pub fn contains_extended(&self, id: u32) -> bool

Check if a message with this extended CAN ID exists.

Source

pub fn dbc(&self) -> &Dbc

Get the underlying Dbc.

Source

pub fn into_dbc(self) -> Dbc

Consume and return the underlying Dbc.

Returns the Dbc if this is the only reference, otherwise clones it.

Source

pub fn ids(&self) -> impl Iterator<Item = u32> + '_

Iterator over all CAN IDs.

Trait Implementations§

Source§

impl Clone for FastDbc

Source§

fn clone(&self) -> FastDbc

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FastDbc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Dbc> for FastDbc

Source§

fn from(dbc: Dbc) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.