Skip to main content

bacnet_client/client/
builder_options.rs

1use super::*;
2
3impl<T: TransportPort + 'static> ClientBuilder<T> {
4    /// Set the independent event notification broadcast channel capacity.
5    pub fn event_channel_capacity(mut self, capacity: usize) -> Self {
6        self.options.event_channel_capacity = capacity;
7        self
8    }
9
10    /// Set the number of APDU retries before a confirmed request times out.
11    pub fn apdu_retries(mut self, retries: u8) -> Self {
12        self.config.apdu_retries = retries;
13        self
14    }
15
16    /// Set the least time, in milliseconds, from the latest confirmed
17    /// request to a destination finishing to the next being sent (default
18    /// 0: no pacing; at most an hour). See
19    /// [`ClientConfig::min_request_interval_ms`].
20    pub fn min_request_interval_ms(mut self, ms: u64) -> Self {
21        self.config.min_request_interval_ms = ms;
22        self
23    }
24
25    /// Set the maximum number of APDU segments this client accepts.
26    ///
27    /// Values 0 and 1 fail at build time. Other finite non-rung values are
28    /// conservatively rounded down in Confirmed-Request headers.
29    pub fn max_segments(mut self, max_segments: Option<u8>) -> Self {
30        self.config.max_segments = max_segments;
31        self
32    }
33
34    /// Set whether this client accepts segmented responses.
35    pub fn segmented_response_accepted(mut self, accepted: bool) -> Self {
36        self.config.segmented_response_accepted = accepted;
37        self
38    }
39
40    /// Set the proposed segmented-transfer window size.
41    pub fn proposed_window_size(mut self, window_size: u8) -> Self {
42        self.config.proposed_window_size = window_size;
43        self
44    }
45
46    /// Set the response policy for decoded ConfirmedCOVNotifications.
47    pub fn confirmed_cov_notification_ack_policy<F>(mut self, policy: F) -> Self
48    where
49        F: Fn(&ReceivedCOVNotification) -> ConfirmedCOVNotificationResponse + Send + Sync + 'static,
50    {
51        self.options = self
52            .options
53            .with_confirmed_cov_notification_ack_policy(policy);
54        self
55    }
56}
57
58impl BipClientBuilder {
59    /// Set the independent event notification broadcast channel capacity.
60    pub fn event_channel_capacity(mut self, capacity: usize) -> Self {
61        self.options.event_channel_capacity = capacity;
62        self
63    }
64
65    /// Set the number of APDU retries before a confirmed request times out.
66    pub fn apdu_retries(mut self, retries: u8) -> Self {
67        self.config.apdu_retries = retries;
68        self
69    }
70
71    /// Set the least time, in milliseconds, from the latest confirmed
72    /// request to a destination finishing to the next being sent (default
73    /// 0: no pacing; at most an hour). See
74    /// [`ClientConfig::min_request_interval_ms`].
75    pub fn min_request_interval_ms(mut self, ms: u64) -> Self {
76        self.config.min_request_interval_ms = ms;
77        self
78    }
79
80    /// Set the maximum number of APDU segments this client accepts.
81    ///
82    /// Values 0 and 1 fail at build time. Other finite non-rung values are
83    /// conservatively rounded down in Confirmed-Request headers.
84    pub fn max_segments(mut self, max_segments: Option<u8>) -> Self {
85        self.config.max_segments = max_segments;
86        self
87    }
88
89    /// Set whether this client accepts segmented responses.
90    pub fn segmented_response_accepted(mut self, accepted: bool) -> Self {
91        self.config.segmented_response_accepted = accepted;
92        self
93    }
94
95    /// Set the proposed segmented-transfer window size.
96    pub fn proposed_window_size(mut self, window_size: u8) -> Self {
97        self.config.proposed_window_size = window_size;
98        self
99    }
100
101    /// Set the response policy for decoded ConfirmedCOVNotifications.
102    pub fn confirmed_cov_notification_ack_policy<F>(mut self, policy: F) -> Self
103    where
104        F: Fn(&ReceivedCOVNotification) -> ConfirmedCOVNotificationResponse + Send + Sync + 'static,
105    {
106        self.options = self
107            .options
108            .with_confirmed_cov_notification_ack_policy(policy);
109        self
110    }
111}
112
113#[cfg(feature = "ipv6")]
114impl Bip6ClientBuilder {
115    /// Set the independent event notification broadcast channel capacity.
116    pub fn event_channel_capacity(mut self, capacity: usize) -> Self {
117        self.options.event_channel_capacity = capacity;
118        self
119    }
120
121    /// Set the number of APDU retries before a confirmed request times out.
122    pub fn apdu_retries(mut self, retries: u8) -> Self {
123        self.config.apdu_retries = retries;
124        self
125    }
126
127    /// Set the least time, in milliseconds, from the latest confirmed
128    /// request to a destination finishing to the next being sent (default
129    /// 0: no pacing; at most an hour). See
130    /// [`ClientConfig::min_request_interval_ms`].
131    pub fn min_request_interval_ms(mut self, ms: u64) -> Self {
132        self.config.min_request_interval_ms = ms;
133        self
134    }
135
136    /// Set the maximum number of APDU segments this client accepts.
137    ///
138    /// Values 0 and 1 fail at build time. Other finite non-rung values are
139    /// conservatively rounded down in Confirmed-Request headers.
140    pub fn max_segments(mut self, max_segments: Option<u8>) -> Self {
141        self.config.max_segments = max_segments;
142        self
143    }
144
145    /// Set whether this client accepts segmented responses.
146    pub fn segmented_response_accepted(mut self, accepted: bool) -> Self {
147        self.config.segmented_response_accepted = accepted;
148        self
149    }
150
151    /// Set the proposed segmented-transfer window size.
152    pub fn proposed_window_size(mut self, window_size: u8) -> Self {
153        self.config.proposed_window_size = window_size;
154        self
155    }
156
157    /// Set the response policy for decoded ConfirmedCOVNotifications.
158    pub fn confirmed_cov_notification_ack_policy<F>(mut self, policy: F) -> Self
159    where
160        F: Fn(&ReceivedCOVNotification) -> ConfirmedCOVNotificationResponse + Send + Sync + 'static,
161    {
162        self.options = self
163            .options
164            .with_confirmed_cov_notification_ack_policy(policy);
165        self
166    }
167}
168
169#[cfg(feature = "sc-tls")]
170impl ScClientBuilder {
171    /// Set the independent event notification broadcast channel capacity.
172    pub fn event_channel_capacity(mut self, capacity: usize) -> Self {
173        self.options.event_channel_capacity = capacity;
174        self
175    }
176
177    /// Set the number of APDU retries before a confirmed request times out.
178    pub fn apdu_retries(mut self, retries: u8) -> Self {
179        self.config.apdu_retries = retries;
180        self
181    }
182
183    /// Set the least time, in milliseconds, from the latest confirmed
184    /// request to a destination finishing to the next being sent (default
185    /// 0: no pacing; at most an hour). See
186    /// [`ClientConfig::min_request_interval_ms`].
187    pub fn min_request_interval_ms(mut self, ms: u64) -> Self {
188        self.config.min_request_interval_ms = ms;
189        self
190    }
191
192    /// Set the maximum number of APDU segments this client accepts.
193    ///
194    /// Values 0 and 1 fail at build time. Other finite non-rung values are
195    /// conservatively rounded down in Confirmed-Request headers.
196    pub fn max_segments(mut self, max_segments: Option<u8>) -> Self {
197        self.config.max_segments = max_segments;
198        self
199    }
200
201    /// Set whether this client accepts segmented responses.
202    pub fn segmented_response_accepted(mut self, accepted: bool) -> Self {
203        self.config.segmented_response_accepted = accepted;
204        self
205    }
206
207    /// Set the proposed segmented-transfer window size.
208    pub fn proposed_window_size(mut self, window_size: u8) -> Self {
209        self.config.proposed_window_size = window_size;
210        self
211    }
212
213    /// Set the response policy for decoded ConfirmedCOVNotifications.
214    pub fn confirmed_cov_notification_ack_policy<F>(mut self, policy: F) -> Self
215    where
216        F: Fn(&ReceivedCOVNotification) -> ConfirmedCOVNotificationResponse + Send + Sync + 'static,
217    {
218        self.options = self
219            .options
220            .with_confirmed_cov_notification_ack_policy(policy);
221        self
222    }
223}