Skip to main content

bacnet_types/
lib.rs

1#![doc = include_str!("../README.md")]
2// Tests always build with std, so feature-off test runs need no imports of
3// their own.
4#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
5#![forbid(unsafe_code)]
6
7// `format!` and `vec!` without std's prelude. Without `alloc` the crate
8// links no allocator at all (#1614).
9#[cfg(feature = "alloc")]
10#[macro_use]
11extern crate alloc;
12
13pub mod bip6_vmac;
14// Its shared views are `Arc`s, which need atomic compare-and-swap (#1615).
15#[cfg(all(feature = "alloc", target_has_atomic = "ptr"))]
16pub mod bip_port;
17pub mod bitstring;
18// Matches the constructed calendar types, which need alloc.
19#[cfg(feature = "alloc")]
20pub mod calendar;
21#[cfg(feature = "alloc")]
22pub mod constructed;
23pub mod data_link;
24pub mod enums;
25pub mod error;
26pub mod map_hash;
27pub mod network_number;
28pub mod primitives;
29pub mod text;
30
31/// BACnet MAC address — stack-allocated for typical sizes (≤6 bytes).
32///
33/// The data links this stack serves use 1-octet (MS/TP), 3-octet (the
34/// B/IPv6 VMAC) and 6-octet (B/IP, Ethernet, the B/SC VMAC) MACs, so SmallVec
35/// keeps every one of them inline. Only with `alloc`.
36#[cfg(feature = "alloc")]
37pub type MacAddr = smallvec::SmallVec<[u8; 6]>;
38
39/// The BACnet protocol version this stack implements: the Device object's
40/// Protocol_Version (Clause 12.11.12).
41///
42/// The Device object and the PICS generator both take it from here, so they
43/// can't disagree (#2125).
44pub const PROTOCOL_VERSION: u16 = 1;
45
46/// The BACnet protocol revision this stack implements: the Device object's
47/// Protocol_Revision (Clause 12.11.13).
48///
49/// The stack implements ASHRAE 135-2020, which the standard's History of
50/// Revisions lists as version 1, revision 22. Later addenda raise the
51/// revision; they are not implemented as a whole, so the stack doesn't claim
52/// them.
53pub const PROTOCOL_REVISION: u16 = 22;