FastDbc

Struct FastDbc 

Source
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

Source

pub fn new(dbc: Dbc) -> Self

Create a new FastDbc wrapper from a Dbc.

This builds a HashMap index for O(1) message lookup.

Source

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.

Source

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

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

Use this for extended CAN IDs.

Source

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.

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
  • Zero allocation
  • Direct buffer write
§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 (with extended flag where applicable).

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.