rustbac_client/value.rs
1use rustbac_core::types::{Date, Time};
2
3/// An owned BACnet application-data value returned by client read operations.
4///
5/// This is the client-side counterpart to the zero-copy `DataValue<'_>` used internally.
6/// All byte-slice and string fields are allocated as owned `Vec`/`String` so the value
7/// can outlive the receive buffer.
8#[derive(Debug, Clone, PartialEq)]
9#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10pub enum ClientDataValue {
11 /// BACnet Null — no value present.
12 Null,
13 /// BACnet Boolean.
14 Boolean(bool),
15 /// BACnet Unsigned Integer (32-bit).
16 Unsigned(u32),
17 /// BACnet Signed Integer (32-bit).
18 Signed(i32),
19 /// BACnet Real (IEEE 754 single-precision float).
20 Real(f32),
21 /// BACnet Double (IEEE 754 double-precision float).
22 Double(f64),
23 /// BACnet Octet String — arbitrary raw bytes.
24 OctetString(Vec<u8>),
25 /// BACnet Character String — UTF-8 text.
26 CharacterString(String),
27 /// BACnet Bit String.
28 ///
29 /// `unused_bits` is the number of padding bits in the last byte of `data` that are not
30 /// part of the logical bit string (0–7).
31 BitString { unused_bits: u8, data: Vec<u8> },
32 /// BACnet Enumerated value — the raw numeric discriminant.
33 Enumerated(u32),
34 /// BACnet Date.
35 Date(Date),
36 /// BACnet Time.
37 Time(Time),
38 /// BACnet ObjectIdentifier — encodes both the object type and instance number.
39 ObjectId(rustbac_core::types::ObjectId),
40 /// A constructed (complex) value containing a sequence of child values.
41 ///
42 /// `tag_num` is the context tag number of the opening/closing tag pair.
43 Constructed {
44 tag_num: u8,
45 values: Vec<ClientDataValue>,
46 },
47}