Skip to main content

bacnet_types/enums/
audit.rs

1// ===========================================================================
2// Audit enums (new in 135-2020)
3// ===========================================================================
4
5bacnet_enum! {
6    /// BACnet audit level (Clause 19.6, new in 135-2020).
7    pub struct AuditLevel(u32);
8
9    const NONE = 0;
10    const AUDIT_ALL = 1;
11    const AUDIT_CONFIG = 2;
12    const DEFAULT = 3;
13}
14
15bacnet_enum! {
16    /// BACnet audit operation (Clause 19.6, new in 135-2020).
17    pub struct AuditOperation(u32);
18
19    const READ = 0;
20    const WRITE = 1;
21    const CREATE = 2;
22    const DELETE = 3;
23    const LIFE_SAFETY = 4;
24    const ACKNOWLEDGE_ALARM = 5;
25    const DEVICE_DISABLE_COMM = 6;
26    const DEVICE_ENABLE_COMM = 7;
27    const DEVICE_RESET = 8;
28    const DEVICE_BACKUP = 9;
29    const DEVICE_RESTORE = 10;
30    const SUBSCRIPTION = 11;
31    const NOTIFICATION = 12;
32    const AUDITING_FAILURE = 13;
33    const NETWORK_CHANGES = 14;
34    const GENERAL = 15;
35}
36
37bacnet_enum! {
38    /// BACnet success filter for audit log queries (Clause 13.19, new in 135-2020).
39    pub struct BACnetSuccessFilter(u32);
40
41    const ALL = 0;
42    const SUCCESSES_ONLY = 1;
43    const FAILURES_ONLY = 2;
44}
45
46impl BACnetSuccessFilter {
47    /// Map the pre-RB-02 Boolean query meaning to the corrected filter.
48    ///
49    /// The uncorrected contract encoded a BOOLEAN `successful-actions-only`:
50    /// `true` selected successes-only and `false` selected all. This helper
51    /// preserves that source-level meaning while moving callers to the
52    /// corrected `BACnetSuccessFilter` type. It accepts exactly one meaning
53    /// per call, touches no wire bytes, and performs no encoding or decoding.
54    ///
55    /// RB-20 completed the migration inventory: 3-state runtime filtering
56    /// including `FAILURES_ONLY` behavior plus storage-predicate
57    /// re-verification (`crates/bacnet-objects/src/audit.rs`
58    /// `operation_matches`/`query_matches`); the Python boundary
59    /// (`crates/rusty-bacnet/src/types/audit.rs`, `rusty_bacnet.pyi`, and
60    /// `crates/rusty-bacnet/tests/test_audit_api.py`); and user-facing docs
61    /// (`rust-api.md`, `python-api.md`, `CHANGELOG`, PICS). Issue #345 stays
62    /// open for reporting/forwarding (RB-21/22).
63    #[deprecated(
64        note = "RB-02 migration aid only: maps the old Boolean meaning (true = successes-only, false = all) to BACnetSuccessFilter; prefer the named ALL / SUCCESSES_ONLY / FAILURES_ONLY constants for new code"
65    )]
66    pub fn from_legacy_bool(successful_actions_only: bool) -> Self {
67        if successful_actions_only {
68            Self::SUCCESSES_ONLY
69        } else {
70            Self::ALL
71        }
72    }
73}