1#[cfg(not(feature = "std"))]
14use alloc::vec::Vec;
15
16pub use bacnet_types::constructed::{
17 AuditPropertyReference, BACnetAuditLogDatum, BACnetAuditLogQueryParameters,
18 BACnetAuditLogRecord, BACnetAuditLogRecordResult, BACnetAuditNotification,
19};
20use bacnet_types::error::Error;
21use bacnet_types::primitives::ObjectIdentifier;
22use bytes::BytesMut;
23
24#[path = "audit/notification_codec.rs"]
25mod notification_codec;
26#[path = "audit/query_ack_codec.rs"]
27mod query_ack_codec;
28#[path = "audit/query_codec.rs"]
29mod query_codec;
30
31#[derive(Debug, Clone, PartialEq)]
33pub struct AuditNotificationRequest {
34 pub notifications: Vec<BACnetAuditNotification>,
36}
37
38#[derive(Debug, Clone, PartialEq)]
43pub struct AuditLogQueryAck {
44 pub audit_log: ObjectIdentifier,
46 pub records: Vec<BACnetAuditLogRecordResult>,
48 pub no_more_items: bool,
50}
51
52#[derive(Debug, Clone, PartialEq, Eq)]
54pub struct AuditLogQueryRequest {
55 pub audit_log: ObjectIdentifier,
57 pub query_parameters: BACnetAuditLogQueryParameters,
59 pub start_at_sequence_number: Option<u64>,
61 pub requested_count: u16,
63}
64
65impl AuditNotificationRequest {
66 pub fn try_encode(&self, buf: &mut BytesMut) -> Result<(), Error> {
68 notification_codec::encode(self, buf)
69 }
70
71 pub fn encode(&self, buf: &mut BytesMut) -> Result<(), Error> {
73 self.try_encode(buf)
74 }
75
76 pub fn decode(data: &[u8]) -> Result<Self, Error> {
78 notification_codec::decode(data)
79 }
80}
81
82impl AuditLogQueryRequest {
83 pub fn try_encode(&self, buf: &mut BytesMut) -> Result<(), Error> {
85 query_codec::encode(self, buf)
86 }
87
88 pub fn encode(&self, buf: &mut BytesMut) -> Result<(), Error> {
90 self.try_encode(buf)
91 }
92
93 pub fn decode(data: &[u8]) -> Result<Self, Error> {
95 query_codec::decode(data)
96 }
97}
98
99impl AuditLogQueryAck {
100 pub fn try_encode(&self, buf: &mut BytesMut) -> Result<(), Error> {
102 query_ack_codec::encode(self, buf)
103 }
104
105 pub fn encode(&self, buf: &mut BytesMut) -> Result<(), Error> {
107 self.try_encode(buf)
108 }
109
110 pub fn decode(data: &[u8]) -> Result<Self, Error> {
112 query_ack_codec::decode(data)
113 }
114}
115
116#[cfg(test)]
117#[path = "audit/tests.rs"]
118mod tests;
119
120#[cfg(test)]
121#[path = "audit/malformed_tests.rs"]
122mod malformed_tests;
123
124#[cfg(test)]
125#[path = "audit/empty_value_tests.rs"]
126mod empty_value_tests;
127
128#[cfg(test)]
129#[path = "audit/address_bound_tests.rs"]
130mod address_bound_tests;