Skip to main content

bacnet_objects/audit/
forwarding.rs

1use bacnet_types::constructed::BACnetDeviceObjectReference;
2
3use super::{AuditLogObject, AuditReporterStatus};
4
5/// Instance-owned, memory-only forwarding configuration and delivery health.
6/// This is not a pending-send queue and does not change the durable snapshot.
7#[doc(hidden)]
8pub struct AuditLogForwarding {
9    parent: BACnetDeviceObjectReference,
10    status: AuditReporterStatus,
11}
12
13impl AuditLogForwarding {
14    /// Locally configured parent; validity and route availability are checked by the server.
15    pub fn parent(&self) -> &BACnetDeviceObjectReference {
16        &self.parent
17    }
18
19    /// Reuse the instance-owned delivery health rules without Reporter production.
20    pub fn status(&self) -> &AuditReporterStatus {
21        &self.status
22    }
23}
24
25impl AuditLogObject {
26    /// Configure immediate, best-effort confirmed forwarding to one parent.
27    ///
28    /// Only the server's explicit `audit_notification_sink` forwards accepted
29    /// notification batches. No backlog is replayed, no records are deleted, and
30    /// restart can lose forwarding progress. Reapply this local configuration on
31    /// restart; it is not part of the persisted snapshot. `None` removes the
32    /// forwarding properties. Invalid/unresolved parents remain visible as
33    /// CONFIGURATION_ERROR and cause no forwarding I/O.
34    pub fn set_member_of(&mut self, parent: Option<BACnetDeviceObjectReference>) {
35        self.forwarding = parent.map(|parent| {
36            std::sync::Arc::new(AuditLogForwarding {
37                parent,
38                status: AuditReporterStatus::default(),
39            })
40        });
41    }
42}