1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! Compatibility layer for `alloc` and `heapless` abstractions.
//!
//! This module provides `String<{N}>`, `Vec<T, {N}>`, and `BTreeMap<K, V, {N}>` types that abstract over
//! `alloc` types (with `alloc` feature) and `heapless` types (with `heapless` feature).
//!
//! # Common Type Aliases
//!
//! - [`Name`] - A name string with `MAX_NAME_SIZE` limit (identifiers, signal names, etc.)
//! - [`ValueDescEntry`] - A value description entry `(value, description)`
//! - [`ValueDescEntries`] - A collection of value description entries
compile_error!;
extern crate alloc;
pub use BTreeMap;
pub use String;
pub use Vec;
use crate::;
/// Maximum size for comment text (CM_ entries).
/// Not defined in DBC spec, using 256 as reasonable default.
pub const MAX_COMMENT_SIZE: usize = 256;
// ============================================================================
// Common Type Aliases
// ============================================================================
/// A name string with `MAX_NAME_SIZE` limit.
///
/// Used for identifiers like signal names, message names, node names, etc.
pub type Name = MAX_NAME_SIZE }>;
/// A comment string with `MAX_COMMENT_SIZE` limit.
///
/// Used for CM_ comment text (messages, signals, nodes, database).
pub type Comment = ;
/// A value description entry: `(numeric_value, description_string)`.
///
/// Used in VAL_ statements to map signal values to human-readable text.
pub type ValueDescEntry = ;
/// A collection of value description entries.
pub type ValueDescEntries = MAX_VALUE_DESCRIPTIONS }>;
/// Helper function to validate and convert a string to a [`Name`] with `MAX_NAME_SIZE` limit.
///
/// This centralizes the common pattern of converting a string reference to
/// [`Name`] with proper error handling.
///
/// # Errors
///
/// Returns `Error::Expected` with `MAX_NAME_SIZE_EXCEEDED` message if the name
/// exceeds `MAX_NAME_SIZE` (32 characters by default, per DBC specification).