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 {
32 unused_bits: u8,
33 data: Vec<u8>,
34 },
35 /// BACnet Enumerated value — the raw numeric discriminant.
36 Enumerated(u32),
37 /// BACnet Date.
38 Date(Date),
39 /// BACnet Time.
40 Time(Time),
41 /// BACnet ObjectIdentifier — encodes both the object type and instance number.
42 ObjectId(rustbac_core::types::ObjectId),
43 /// A constructed (complex) value containing a sequence of child values.
44 ///
45 /// `tag_num` is the context tag number of the opening/closing tag pair.
46 Constructed {
47 tag_num: u8,
48 values: Vec<ClientDataValue>,
49 },
50}