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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use std::{error::Error, fmt};
#[derive(Debug)]
pub struct AttributeIdError;
impl fmt::Display for AttributeIdError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "AttributeIdError")
}
}
impl Error for AttributeIdError {}
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)]
pub enum AttributeId {
NodeId = 1,
NodeClass = 2,
BrowseName = 3,
DisplayName = 4,
Description = 5,
WriteMask = 6,
UserWriteMask = 7,
IsAbstract = 8,
Symmetric = 9,
InverseName = 10,
ContainsNoLoops = 11,
EventNotifier = 12,
Value = 13,
DataType = 14,
ValueRank = 15,
ArrayDimensions = 16,
AccessLevel = 17,
UserAccessLevel = 18,
MinimumSamplingInterval = 19,
Historizing = 20,
Executable = 21,
UserExecutable = 22,
DataTypeDefinition = 23,
RolePermissions = 24,
UserRolePermissions = 25,
AccessRestrictions = 26,
AccessLevelEx = 27,
}
impl AttributeId {
pub fn from_u32(attribute_id: u32) -> Result<AttributeId, AttributeIdError> {
let attribute_id = match attribute_id {
1 => AttributeId::NodeId,
2 => AttributeId::NodeClass,
3 => AttributeId::BrowseName,
4 => AttributeId::DisplayName,
5 => AttributeId::Description,
6 => AttributeId::WriteMask,
7 => AttributeId::UserWriteMask,
8 => AttributeId::IsAbstract,
9 => AttributeId::Symmetric,
10 => AttributeId::InverseName,
11 => AttributeId::ContainsNoLoops,
12 => AttributeId::EventNotifier,
13 => AttributeId::Value,
14 => AttributeId::DataType,
15 => AttributeId::ValueRank,
16 => AttributeId::ArrayDimensions,
17 => AttributeId::AccessLevel,
18 => AttributeId::UserAccessLevel,
19 => AttributeId::MinimumSamplingInterval,
20 => AttributeId::Historizing,
21 => AttributeId::Executable,
22 => AttributeId::UserExecutable,
23 => AttributeId::DataTypeDefinition,
24 => AttributeId::RolePermissions,
25 => AttributeId::UserRolePermissions,
26 => AttributeId::AccessRestrictions,
27 => AttributeId::AccessLevelEx,
_ => {
debug!("Invalid attribute id {}", attribute_id);
return Err(AttributeIdError);
}
};
Ok(attribute_id)
}
}