dbc_rs/lib.rs
1//! # dbc-rs
2//!
3//! A clean, zero-dependency DBC (CAN Database) file parser and editor for Rust.
4//!
5//! This library provides a complete solution for parsing, validating, and writing DBC files
6//! in both `std` and `no_std` environments. It supports the core DBC file format features
7//! including messages, signals, nodes, and version information.
8//!
9//! ## Features
10//!
11//! - **Zero dependencies** - Pure Rust implementation
12//! - **no_std + alloc support** - Works on embedded targets without the standard library
13//! - **Full parsing and writing** - Parse DBC files and save them back
14//! - **Comprehensive validation** - CAN ID range validation, signal overlap detection, and more
15//! - **Internationalization** - Error messages in multiple languages (build-time selection)
16//!
17//! ## Quick Start
18//!
19//! ```rust
20//! use dbc_rs::Dbc;
21//!
22//! let content = "VERSION \"1.0\"\n\nBU_: ECM\n\nBO_ 256 Engine : 8 ECM\n SG_ RPM : 0|16@1+ (0.25,0) [0|8000] \"rpm\"";
23//! let dbc = Dbc::parse(content)?;
24//!
25//! println!("Version: {}", dbc.version().to_string());
26//! println!("Messages: {}", dbc.messages().len());
27//! # Ok::<(), dbc_rs::Error>(())
28//! ```
29//!
30//! ## Core Types
31//!
32//! - [`Dbc`] - The main structure representing a complete DBC file
33//! - [`Message`] - Represents a CAN message with ID, name, DLC, sender, and signals
34//! - [`Signal`] - Represents a signal within a message with scaling, offset, min/max, etc.
35//! - [`Nodes`] - Represents the list of ECUs/nodes on the CAN bus
36//! - [`Version`] - Represents the DBC file version (major.minor.patch)
37//! - [`Error`] - Error type for parsing and validation failures
38//!
39//! ## Module Structure
40//!
41//! The library is organized into modules:
42//! - Main DBC file structure and parsing logic (see [`Dbc`])
43//! - CAN message definitions (see [`Message`])
44//! - Signal definitions with validation (see [`Signal`])
45//! - Node/ECU management (see [`Nodes`])
46//! - Version string parsing and validation (see [`Version`])
47//! - Error types and internationalized error messages (see [`Error`])
48//!
49//! ## See Also
50//!
51//! - [README.md](../README.md) - Comprehensive documentation and examples
52//! - [Examples](../examples/) - Usage examples
53
54#![cfg_attr(not(feature = "std"), no_std)]
55#![deny(missing_docs)]
56#![deny(unsafe_code)]
57
58extern crate alloc;
59
60mod dbc;
61mod error;
62mod message;
63mod nodes;
64mod signal;
65mod version;
66
67pub use dbc::Dbc;
68pub use error::Error;
69pub use message::Message;
70pub use nodes::Nodes;
71pub use signal::{ByteOrder, Receivers, Signal};
72pub use version::Version;
73
74/// Library version
75pub const VERSION: &str = env!("CARGO_PKG_VERSION");