bacnet_types/constructed/property_access.rs
1//! The result of reading one referenced property (`BACnetPropertyAccessResult`,
2//! Clause 21): the element type of a Global Group's Present_Value array
3//! (Clause 12.50.7).
4
5use super::BACnetDeviceObjectPropertyReference;
6use crate::enums::{ErrorClass, ErrorCode};
7use crate::primitives::PropertyValue;
8
9/// What reading one property produced: the value, or the error the read
10/// failed with (the `access-result` choice of `BACnetPropertyAccessResult`).
11///
12/// On the wire the value sits inside context tag `[4]` and the error, an
13/// application-tagged class then code, inside context tag `[5]`.
14#[derive(Debug, Clone, PartialEq)]
15pub enum AccessResult {
16 /// The value the read returned.
17 Value(PropertyValue),
18 /// The read failed with this error.
19 Error {
20 /// The error class.
21 class: ErrorClass,
22 /// The error code.
23 code: ErrorCode,
24 },
25}
26
27impl AccessResult {
28 /// PROPERTY / VALUE_NOT_INITIALIZED: what a Global Group holds for a
29 /// member whose value it has not acquired yet (Clause 12.50.7.1).
30 pub const NOT_INITIALIZED: Self = Self::Error {
31 class: ErrorClass::PROPERTY,
32 code: ErrorCode::VALUE_NOT_INITIALIZED,
33 };
34}
35
36/// A property reference together with what reading it produced
37/// (`BACnetPropertyAccessResult`, Clause 21).
38///
39/// The reference goes out exactly as a [`BACnetDeviceObjectPropertyReference`]
40/// does, context tags `[0]` to `[3]` with the array index and the device
41/// optional, and the [`AccessResult`] follows. The codec is
42/// `bacnet_encoding::constructed::{encode_property_access_result,
43/// decode_property_access_result}`.
44#[derive(Debug, Clone, PartialEq)]
45pub struct BACnetPropertyAccessResult {
46 /// The property that was read.
47 pub reference: BACnetDeviceObjectPropertyReference,
48 /// What the read produced.
49 pub access_result: AccessResult,
50}