1mod helpers;
2mod impls;
3mod lang;
4
5pub(crate) use helpers::{check_max_limit, map_val_error, map_val_error_with_line};
6
7#[derive(Debug, PartialEq, Clone)]
12pub enum Error {
13 UnexpectedEof { line: Option<usize> },
15 Expected {
17 msg: &'static str,
18 line: Option<usize>,
19 },
20 InvalidChar { char: char, line: Option<usize> },
22 MaxStrLength { max: usize, line: Option<usize> },
24 Version {
26 msg: &'static str,
27 line: Option<usize>,
28 },
29 Message {
31 msg: &'static str,
32 line: Option<usize>,
33 },
34 Receivers {
36 msg: &'static str,
37 line: Option<usize>,
38 },
39 Nodes {
41 msg: &'static str,
42 line: Option<usize>,
43 },
44 Signal {
46 msg: &'static str,
47 line: Option<usize>,
48 },
49 Decoding(&'static str),
51 Encoding(&'static str),
53 Validation(&'static str),
55}
56
57impl Error {
58 pub const UNEXPECTED_EOF: &'static str = lang::UNEXPECTED_EOF;
63 pub const EXPECTED_WHITESPACE: &'static str = lang::EXPECTED_WHITESPACE;
64 pub const EXPECTED_PATTERN: &'static str = lang::EXPECTED_PATTERN;
65 pub const EXPECTED_KEYWORD: &'static str = lang::EXPECTED_KEYWORD;
66 pub const EXPECTED_NUMBER: &'static str = lang::EXPECTED_NUMBER;
67 pub const EXPECTED_IDENTIFIER: &'static str = lang::EXPECTED_IDENTIFIER;
68 pub const INVALID_UTF8: &'static str = lang::INVALID_UTF8;
69 pub const INVALID_NUMBER_FORMAT: &'static str = lang::INVALID_NUMBER_FORMAT;
70 pub const PARSE_NUMBER_FAILED: &'static str = lang::PARSE_NUMBER_FAILED;
71 pub const INVALID_CHARACTER: &'static str = lang::INVALID_CHARACTER;
72 pub const STRING_LENGTH_EXCEEDS_MAX: &'static str = lang::STRING_LENGTH_EXCEEDS_MAX;
73 pub const MAX_NAME_SIZE_EXCEEDED: &'static str = lang::MAX_NAME_SIZE_EXCEEDED;
74
75 pub const DECODING_ERROR_PREFIX: &'static str = lang::DECODING_ERROR_PREFIX;
77 pub const VALIDATION_ERROR_PREFIX: &'static str = lang::VALIDATION_ERROR_PREFIX;
78 pub const VERSION_ERROR_PREFIX: &'static str = lang::VERSION_ERROR_PREFIX;
79 pub const MESSAGE_ERROR_PREFIX: &'static str = lang::MESSAGE_ERROR_PREFIX;
80 pub const RECEIVERS_ERROR_PREFIX: &'static str = lang::RECEIVERS_ERROR_PREFIX;
81 pub const NODES_ERROR_PREFIX: &'static str = lang::NODES_ERROR_PREFIX;
82 pub const SIGNAL_ERROR_PREFIX: &'static str = lang::SIGNAL_ERROR_PREFIX;
83
84 pub const SIGNAL_PARSE_INVALID_START_BIT: &'static str = lang::SIGNAL_PARSE_INVALID_START_BIT;
86 pub const SIGNAL_PARSE_INVALID_LENGTH: &'static str = lang::SIGNAL_PARSE_INVALID_LENGTH;
87 pub const SIGNAL_PARSE_INVALID_FACTOR: &'static str = lang::SIGNAL_PARSE_INVALID_FACTOR;
88 pub const SIGNAL_PARSE_INVALID_OFFSET: &'static str = lang::SIGNAL_PARSE_INVALID_OFFSET;
89 pub const SIGNAL_PARSE_INVALID_MIN: &'static str = lang::SIGNAL_PARSE_INVALID_MIN;
90 pub const SIGNAL_PARSE_INVALID_MAX: &'static str = lang::SIGNAL_PARSE_INVALID_MAX;
91 pub const SIGNAL_PARSE_UNIT_TOO_LONG: &'static str = lang::SIGNAL_PARSE_UNIT_TOO_LONG;
92 pub const SIGNAL_NAME_EMPTY: &'static str = lang::SIGNAL_NAME_EMPTY;
93 pub const SIGNAL_LENGTH_TOO_SMALL: &'static str = lang::SIGNAL_LENGTH_TOO_SMALL;
94 pub const SIGNAL_LENGTH_TOO_LARGE: &'static str = lang::SIGNAL_LENGTH_TOO_LARGE;
95 #[cfg(feature = "std")]
96 pub const SIGNAL_LENGTH_REQUIRED: &'static str = lang::SIGNAL_LENGTH_REQUIRED;
97 #[cfg(feature = "std")]
98 pub const SIGNAL_START_BIT_REQUIRED: &'static str = lang::SIGNAL_START_BIT_REQUIRED;
99 #[cfg(feature = "std")]
100 pub const SIGNAL_BYTE_ORDER_REQUIRED: &'static str = lang::SIGNAL_BYTE_ORDER_REQUIRED;
101 #[cfg(feature = "std")]
102 pub const SIGNAL_UNSIGNED_REQUIRED: &'static str = lang::SIGNAL_UNSIGNED_REQUIRED;
103 #[cfg(feature = "std")]
104 pub const SIGNAL_FACTOR_REQUIRED: &'static str = lang::SIGNAL_FACTOR_REQUIRED;
105 #[cfg(feature = "std")]
106 pub const SIGNAL_OFFSET_REQUIRED: &'static str = lang::SIGNAL_OFFSET_REQUIRED;
107 #[cfg(feature = "std")]
108 pub const SIGNAL_MIN_REQUIRED: &'static str = lang::SIGNAL_MIN_REQUIRED;
109 #[cfg(feature = "std")]
110 pub const SIGNAL_MAX_REQUIRED: &'static str = lang::SIGNAL_MAX_REQUIRED;
111 pub const SIGNAL_OVERLAP: &'static str = lang::SIGNAL_OVERLAP;
112 pub const SIGNAL_EXTENDS_BEYOND_MESSAGE: &'static str = lang::SIGNAL_EXTENDS_BEYOND_MESSAGE;
113 pub const SIGNAL_EXTENDS_BEYOND_DATA: &'static str = lang::SIGNAL_EXTENDS_BEYOND_DATA;
114 pub const SIGNAL_RECEIVERS_TOO_MANY: &'static str = lang::SIGNAL_RECEIVERS_TOO_MANY;
115
116 pub const NODES_DUPLICATE_NAME: &'static str = lang::NODES_DUPLICATE_NAME;
118 pub const NODES_TOO_MANY: &'static str = lang::NODES_TOO_MANY;
119 pub const DUPLICATE_MESSAGE_ID: &'static str = lang::DUPLICATE_MESSAGE_ID;
120 pub const SENDER_NOT_IN_NODES: &'static str = lang::SENDER_NOT_IN_NODES;
121 pub const INVALID_RANGE: &'static str = lang::INVALID_RANGE;
122 pub const MESSAGE_TOO_MANY_SIGNALS: &'static str = lang::MESSAGE_TOO_MANY_SIGNALS;
123 pub const EXTENDED_MULTIPLEXING_TOO_MANY: &'static str = lang::EXTENDED_MULTIPLEXING_TOO_MANY;
124 pub const MESSAGE_NAME_EMPTY: &'static str = lang::MESSAGE_NAME_EMPTY;
125 pub const MESSAGE_SENDER_EMPTY: &'static str = lang::MESSAGE_SENDER_EMPTY;
126 pub const MESSAGE_DLC_TOO_SMALL: &'static str = lang::MESSAGE_DLC_TOO_SMALL;
127 pub const MESSAGE_DLC_TOO_LARGE: &'static str = lang::MESSAGE_DLC_TOO_LARGE;
128 #[cfg(feature = "std")]
129 pub const MESSAGE_DLC_REQUIRED: &'static str = lang::MESSAGE_DLC_REQUIRED;
130 pub const MESSAGE_ID_OUT_OF_RANGE: &'static str = lang::MESSAGE_ID_OUT_OF_RANGE;
131 #[cfg(feature = "std")]
132 pub const MESSAGE_ID_REQUIRED: &'static str = lang::MESSAGE_ID_REQUIRED;
133 pub const MESSAGE_INVALID_ID: &'static str = lang::MESSAGE_INVALID_ID;
134 pub const MESSAGE_INVALID_DLC: &'static str = lang::MESSAGE_INVALID_DLC;
135 pub const MESSAGE_NOT_FOUND: &'static str = lang::MESSAGE_NOT_FOUND;
136 pub const PAYLOAD_LENGTH_MISMATCH: &'static str = lang::PAYLOAD_LENGTH_MISMATCH;
137 pub const MULTIPLEXER_SWITCH_NEGATIVE: &'static str = lang::MULTIPLEXER_SWITCH_NEGATIVE;
138 #[cfg(feature = "std")]
139 pub const RECEIVERS_DUPLICATE_NAME: &'static str = lang::RECEIVERS_DUPLICATE_NAME;
140
141 pub const VALUE_DESCRIPTION_MESSAGE_NOT_FOUND: &'static str =
143 lang::VALUE_DESCRIPTION_MESSAGE_NOT_FOUND;
144 pub const VALUE_DESCRIPTION_SIGNAL_NOT_FOUND: &'static str =
145 lang::VALUE_DESCRIPTION_SIGNAL_NOT_FOUND;
146 pub const VALUE_DESCRIPTIONS_TOO_MANY: &'static str = lang::VALUE_DESCRIPTIONS_TOO_MANY;
147 pub const VALUE_DESCRIPTIONS_EMPTY: &'static str = lang::VALUE_DESCRIPTIONS_EMPTY;
148
149 pub const EXT_MUX_MESSAGE_NOT_FOUND: &'static str = lang::EXT_MUX_MESSAGE_NOT_FOUND;
151 pub const EXT_MUX_SIGNAL_NOT_FOUND: &'static str = lang::EXT_MUX_SIGNAL_NOT_FOUND;
152 pub const EXT_MUX_SWITCH_NOT_FOUND: &'static str = lang::EXT_MUX_SWITCH_NOT_FOUND;
153 pub const EXT_MUX_INVALID_RANGE: &'static str = lang::EXT_MUX_INVALID_RANGE;
154
155 pub const ENCODING_ERROR_PREFIX: &'static str = lang::ENCODING_ERROR_PREFIX;
157 pub const ENCODING_SIGNAL_NOT_FOUND: &'static str = lang::ENCODING_SIGNAL_NOT_FOUND;
158 pub const ENCODING_VALUE_OUT_OF_RANGE: &'static str = lang::ENCODING_VALUE_OUT_OF_RANGE;
159 pub const ENCODING_VALUE_OVERFLOW: &'static str = lang::ENCODING_VALUE_OVERFLOW;
160}
161
162pub type Result<T> = core::result::Result<T, Error>;