1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Local limits for the deprecated GetEnrollmentSummary interoperability service.
use super::*;
/// Positive limits on total database objects and complete logical ACK bytes.
///
/// Counts all objects before any callbacks, after request decoding. Bytes exclude
/// APDU/NPDU and are independent of peer APDU size and segmentation. Does not bound
/// request decoding, individual callbacks/reads, recipient-list processing,
/// allocation capacity/OOM, RSS, CPU or deadlines. Reads are not rolled back.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct GetEnrollmentSummaryBudget {
/// Maximum total database objects, including noncandidates and classes (4096).
pub max_objects: usize,
/// Maximum encoded service ACK logical bytes (16384).
pub max_service_ack_bytes: usize,
}
impl Default for GetEnrollmentSummaryBudget {
fn default() -> Self {
Self {
max_objects: 4096,
max_service_ack_bytes: 16384,
}
}
}
impl GetEnrollmentSummaryBudget {
/// Reject zero; positive limits are local operator policy, not BACnet limits.
pub fn validate(&self) -> Result<(), Error> {
for (name, value) in [
("enrollment_summary_max_objects", self.max_objects),
(
"enrollment_summary_max_service_ack_bytes",
self.max_service_ack_bytes,
),
] {
if value == 0 {
return Err(Error::Encoding(format!("{name} must be positive")));
}
}
Ok(())
}
}
impl<T: TransportPort + 'static> ServerBuilder<T> {
/// Set GetEnrollmentSummary limits validated before transport startup.
pub fn get_enrollment_summary_budget(mut self, budget: GetEnrollmentSummaryBudget) -> Self {
self.config.get_enrollment_summary_budget = budget;
self
}
}
impl BipServerBuilder {
/// Set GetEnrollmentSummary limits validated before transport startup.
pub fn get_enrollment_summary_budget(mut self, budget: GetEnrollmentSummaryBudget) -> Self {
self.config.get_enrollment_summary_budget = budget;
self
}
}
#[cfg(feature = "sc-tls")]
impl ScServerBuilder {
/// Set GetEnrollmentSummary limits validated before SC dialing.
pub fn get_enrollment_summary_budget(mut self, budget: GetEnrollmentSummaryBudget) -> Self {
self.config.get_enrollment_summary_budget = budget;
self
}
}