dbc-rs
A lightweight Rust library for seamlessly parsing and editing DBC (CAN Database) files, with robust support for encoding and decoding messages and signals.
Maintained by Sigma Tactical Group for embedded CAN tooling in the Sigma stack. The crates.io package name dbc-rs is unchanged for semver continuity. Earlier standalone development and contributors are upstream lineage — see CONTRIBUTORS.md.
Features
- Zero dependencies - Pure Rust, no external runtime dependencies
- no_std compatible - Works on embedded targets (Cortex-M, RISC-V)
- Flexible memory - Heap (
alloc) or stack (heapless) allocation - Memory safe -
forbid(unsafe_code)enforced - Full read/write - Parse, modify, and serialize DBC files
Embedded-first
DBC-facing specifics: no_std with heapless or alloc; compile-time MAX_* caps (build.rs); sigma-bounded primitives re-exported from compat/.
Further detail: ARCHITECTURE.md.
Quick Start
[]
= "0.5"
Decode CAN Frames
use Dbc;
// Parse DBC content
let dbc = parse?;
// Decode a CAN frame (ID 0x100, 8 bytes, standard 11-bit ID)
let signals = dbc.decode?;
for signal in signals
Encode Signal Values
use Dbc;
let dbc = parse?;
// Encode signal values into a CAN frame payload (standard 11-bit ID)
let payload = dbc.encode?;
Embedded (no_std)
[]
= { = "0.7", = false, = ["heapless"] }
# heapless capacities are compile-time inline storage, sized for embedded
# safety-bus DBCs by default (16 messages × 8 signals, 8 nodes …). For
# larger DBCs either use the `alloc` feature or raise the caps at build
# time via env vars: DBC_MAX_MESSAGES, DBC_MAX_SIGNALS_PER_MESSAGE,
# DBC_MAX_NODES, DBC_MAX_VALUE_DESCRIPTIONS, DBC_MAX_NAME_SIZE,
# DBC_MAX_EXTENDED_MULTIPLEXING (powers of 2 where required).
See examples/ for complete working examples:
decode.rs- Signal decoding basicsdecode_frame.rs- Usingembedded-canFrame traitencode.rs- Encoding signals to CAN payloadscreate_dbc.rs- Building DBC files programmaticallyparse_std.rs/parse_no_std.rs- Parsing in different environments
Feature Flags
| Feature | Description | Default |
|---|---|---|
std |
Standard library with builders | Yes |
alloc |
Heap allocation | Via std |
heapless |
Stack-only for no_std |
No |
embedded-can |
embedded-can crate integration |
No |
attributes |
BA_DEF_, BA_DEF_DEF_, BA_ support | Yes |
Minimum Supported Rust Version (MSRV)
dbc-rs requires Rust 1.97.0 or later (edition 2024). Bumping the MSRV is considered a minor breaking change and will be noted in release notes.
Documentation
- API Reference
- ARCHITECTURE.md - Internal design (includes Embedded-first)
- SPECIFICATIONS.md - DBC format reference
- SECURITY.md - Security audit
Brand & artwork
© Sigma Tactical Group. All rights reserved.
The Sigma Tactical Group name, logos, marks, artwork, and visual identity are proprietary. They are not covered by this repository's source-code license. See BRANDING.md.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.