Skip to main content

bacnet_client/client/
builder_options.rs

1use super::*;
2
3impl<T: TransportPort + 'static> ClientBuilder<T> {
4    /// Set the number of APDU retries before a confirmed request times out.
5    pub fn apdu_retries(mut self, retries: u8) -> Self {
6        self.config.apdu_retries = retries;
7        self
8    }
9
10    /// Set the maximum number of APDU segments this client accepts.
11    ///
12    /// Values 0 and 1 fail at build time. Other finite non-rung values are
13    /// conservatively rounded down in Confirmed-Request headers.
14    pub fn max_segments(mut self, max_segments: Option<u8>) -> Self {
15        self.config.max_segments = max_segments;
16        self
17    }
18
19    /// Set whether this client accepts segmented responses.
20    pub fn segmented_response_accepted(mut self, accepted: bool) -> Self {
21        self.config.segmented_response_accepted = accepted;
22        self
23    }
24
25    /// Set the proposed segmented-transfer window size.
26    pub fn proposed_window_size(mut self, window_size: u8) -> Self {
27        self.config.proposed_window_size = window_size;
28        self
29    }
30
31    /// Set the response policy for decoded ConfirmedCOVNotifications.
32    pub fn confirmed_cov_notification_ack_policy<F>(mut self, policy: F) -> Self
33    where
34        F: Fn(&ReceivedCOVNotification) -> ConfirmedCOVNotificationResponse + Send + Sync + 'static,
35    {
36        self.options = self
37            .options
38            .with_confirmed_cov_notification_ack_policy(policy);
39        self
40    }
41}
42
43impl BipClientBuilder {
44    /// Set the number of APDU retries before a confirmed request times out.
45    pub fn apdu_retries(mut self, retries: u8) -> Self {
46        self.config.apdu_retries = retries;
47        self
48    }
49
50    /// Set the maximum number of APDU segments this client accepts.
51    ///
52    /// Values 0 and 1 fail at build time. Other finite non-rung values are
53    /// conservatively rounded down in Confirmed-Request headers.
54    pub fn max_segments(mut self, max_segments: Option<u8>) -> Self {
55        self.config.max_segments = max_segments;
56        self
57    }
58
59    /// Set whether this client accepts segmented responses.
60    pub fn segmented_response_accepted(mut self, accepted: bool) -> Self {
61        self.config.segmented_response_accepted = accepted;
62        self
63    }
64
65    /// Set the proposed segmented-transfer window size.
66    pub fn proposed_window_size(mut self, window_size: u8) -> Self {
67        self.config.proposed_window_size = window_size;
68        self
69    }
70
71    /// Set the response policy for decoded ConfirmedCOVNotifications.
72    pub fn confirmed_cov_notification_ack_policy<F>(mut self, policy: F) -> Self
73    where
74        F: Fn(&ReceivedCOVNotification) -> ConfirmedCOVNotificationResponse + Send + Sync + 'static,
75    {
76        self.options = self
77            .options
78            .with_confirmed_cov_notification_ack_policy(policy);
79        self
80    }
81}
82
83#[cfg(feature = "ipv6")]
84impl Bip6ClientBuilder {
85    /// Set the number of APDU retries before a confirmed request times out.
86    pub fn apdu_retries(mut self, retries: u8) -> Self {
87        self.config.apdu_retries = retries;
88        self
89    }
90
91    /// Set the maximum number of APDU segments this client accepts.
92    ///
93    /// Values 0 and 1 fail at build time. Other finite non-rung values are
94    /// conservatively rounded down in Confirmed-Request headers.
95    pub fn max_segments(mut self, max_segments: Option<u8>) -> Self {
96        self.config.max_segments = max_segments;
97        self
98    }
99
100    /// Set whether this client accepts segmented responses.
101    pub fn segmented_response_accepted(mut self, accepted: bool) -> Self {
102        self.config.segmented_response_accepted = accepted;
103        self
104    }
105
106    /// Set the proposed segmented-transfer window size.
107    pub fn proposed_window_size(mut self, window_size: u8) -> Self {
108        self.config.proposed_window_size = window_size;
109        self
110    }
111
112    /// Set the response policy for decoded ConfirmedCOVNotifications.
113    pub fn confirmed_cov_notification_ack_policy<F>(mut self, policy: F) -> Self
114    where
115        F: Fn(&ReceivedCOVNotification) -> ConfirmedCOVNotificationResponse + Send + Sync + 'static,
116    {
117        self.options = self
118            .options
119            .with_confirmed_cov_notification_ack_policy(policy);
120        self
121    }
122}
123
124#[cfg(feature = "sc-tls")]
125impl ScClientBuilder {
126    /// Set the number of APDU retries before a confirmed request times out.
127    pub fn apdu_retries(mut self, retries: u8) -> Self {
128        self.config.apdu_retries = retries;
129        self
130    }
131
132    /// Set the maximum number of APDU segments this client accepts.
133    ///
134    /// Values 0 and 1 fail at build time. Other finite non-rung values are
135    /// conservatively rounded down in Confirmed-Request headers.
136    pub fn max_segments(mut self, max_segments: Option<u8>) -> Self {
137        self.config.max_segments = max_segments;
138        self
139    }
140
141    /// Set whether this client accepts segmented responses.
142    pub fn segmented_response_accepted(mut self, accepted: bool) -> Self {
143        self.config.segmented_response_accepted = accepted;
144        self
145    }
146
147    /// Set the proposed segmented-transfer window size.
148    pub fn proposed_window_size(mut self, window_size: u8) -> Self {
149        self.config.proposed_window_size = window_size;
150        self
151    }
152
153    /// Set the response policy for decoded ConfirmedCOVNotifications.
154    pub fn confirmed_cov_notification_ack_policy<F>(mut self, policy: F) -> Self
155    where
156        F: Fn(&ReceivedCOVNotification) -> ConfirmedCOVNotificationResponse + Send + Sync + 'static,
157    {
158        self.options = self
159            .options
160            .with_confirmed_cov_notification_ack_policy(policy);
161        self
162    }
163}