can_dbc/ast/
extended_multiplex_mapping.rs1use can_dbc_pest::{Pair, Rule};
2
3use crate::parser::{expect_empty, parse_next_uint, validated_inner, DbcError};
4
5#[derive(Clone, Debug, PartialEq)]
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7pub struct ExtendedMultiplexMapping {
8 pub min_value: u64,
9 pub max_value: u64,
10}
11
12impl TryFrom<Pair<'_, Rule>> for ExtendedMultiplexMapping {
13 type Error = DbcError;
14
15 fn try_from(value: Pair<'_, Rule>) -> Result<Self, Self::Error> {
16 let mut pairs = validated_inner(value, Rule::value_pair)?;
17 let value = ExtendedMultiplexMapping {
18 min_value: parse_next_uint(&mut pairs, Rule::uint)?,
19 max_value: parse_next_uint(&mut pairs, Rule::uint)?,
20 };
21 expect_empty(&pairs)?;
22 Ok(value)
23 }
24}