Skip to main content

dbc_rs/attribute/
attribute_definition.rs

1//! [`AttributeDefinition`].
2
3#[allow(unused_imports)]
4use super::*;
5use crate::compat::Name;
6
7/// Attribute definition from BA_DEF_.
8///
9/// Defines an attribute's name, target object type, and value type.
10///
11/// # Example
12///
13/// ```text
14/// BA_DEF_ BO_ "GenMsgCycleTime" INT 0 10000;
15/// ```
16///
17/// This defines a message attribute named "GenMsgCycleTime" with
18/// integer values in range 0-10000.
19#[derive(Debug, Clone, PartialEq)]
20pub struct AttributeDefinition {
21    /// Attribute name (quoted identifier in DBC)
22    pub(crate) name: Name,
23    /// Target object type (Network, Node, Message, Signal)
24    pub(crate) object_type: AttributeObjectType,
25    /// Value type specification
26    pub(crate) value_type: AttributeValueType,
27}
28impl AttributeDefinition {
29    /// Creates a new attribute definition.
30    #[inline]
31    pub(crate) fn new(
32        name: Name,
33        object_type: AttributeObjectType,
34        value_type: AttributeValueType,
35    ) -> Self {
36        Self {
37            name,
38            object_type,
39            value_type,
40        }
41    }
42}