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    /// Make the client a foreign device of a B/IPv6 BBMD (Annex U.4.5),
116    /// which then carries its broadcasts. Needs
117    /// [`Self::device_instance`]; the build fails without one, or when the
118    /// registration fails [`Bip6ForeignDeviceConfig::check`].
119    pub fn foreign_device(mut self, config: Bip6ForeignDeviceConfig) -> Self {
120        self.foreign_device = Some(config);
121        self
122    }
123
124    /// Set the independent event notification broadcast channel capacity.
125    pub fn event_channel_capacity(mut self, capacity: usize) -> Self {
126        self.options.event_channel_capacity = capacity;
127        self
128    }
129
130    /// Set the number of APDU retries before a confirmed request times out.
131    pub fn apdu_retries(mut self, retries: u8) -> Self {
132        self.config.apdu_retries = retries;
133        self
134    }
135
136    /// Set the least time, in milliseconds, from the latest confirmed
137    /// request to a destination finishing to the next being sent (default
138    /// 0: no pacing; at most an hour). See
139    /// [`ClientConfig::min_request_interval_ms`].
140    pub fn min_request_interval_ms(mut self, ms: u64) -> Self {
141        self.config.min_request_interval_ms = ms;
142        self
143    }
144
145    /// Set the maximum number of APDU segments this client accepts.
146    ///
147    /// Values 0 and 1 fail at build time. Other finite non-rung values are
148    /// conservatively rounded down in Confirmed-Request headers.
149    pub fn max_segments(mut self, max_segments: Option<u8>) -> Self {
150        self.config.max_segments = max_segments;
151        self
152    }
153
154    /// Set whether this client accepts segmented responses.
155    pub fn segmented_response_accepted(mut self, accepted: bool) -> Self {
156        self.config.segmented_response_accepted = accepted;
157        self
158    }
159
160    /// Set the proposed segmented-transfer window size.
161    pub fn proposed_window_size(mut self, window_size: u8) -> Self {
162        self.config.proposed_window_size = window_size;
163        self
164    }
165
166    /// Set the response policy for decoded ConfirmedCOVNotifications.
167    pub fn confirmed_cov_notification_ack_policy<F>(mut self, policy: F) -> Self
168    where
169        F: Fn(&ReceivedCOVNotification) -> ConfirmedCOVNotificationResponse + Send + Sync + 'static,
170    {
171        self.options = self
172            .options
173            .with_confirmed_cov_notification_ack_policy(policy);
174        self
175    }
176}
177
178#[cfg(feature = "sc-tls")]
179impl ScClientBuilder {
180    /// Set the independent event notification broadcast channel capacity.
181    pub fn event_channel_capacity(mut self, capacity: usize) -> Self {
182        self.options.event_channel_capacity = capacity;
183        self
184    }
185
186    /// Set the number of APDU retries before a confirmed request times out.
187    pub fn apdu_retries(mut self, retries: u8) -> Self {
188        self.config.apdu_retries = retries;
189        self
190    }
191
192    /// Set the least time, in milliseconds, from the latest confirmed
193    /// request to a destination finishing to the next being sent (default
194    /// 0: no pacing; at most an hour). See
195    /// [`ClientConfig::min_request_interval_ms`].
196    pub fn min_request_interval_ms(mut self, ms: u64) -> Self {
197        self.config.min_request_interval_ms = ms;
198        self
199    }
200
201    /// Set the maximum number of APDU segments this client accepts.
202    ///
203    /// Values 0 and 1 fail at build time. Other finite non-rung values are
204    /// conservatively rounded down in Confirmed-Request headers.
205    pub fn max_segments(mut self, max_segments: Option<u8>) -> Self {
206        self.config.max_segments = max_segments;
207        self
208    }
209
210    /// Set whether this client accepts segmented responses.
211    pub fn segmented_response_accepted(mut self, accepted: bool) -> Self {
212        self.config.segmented_response_accepted = accepted;
213        self
214    }
215
216    /// Set the proposed segmented-transfer window size.
217    pub fn proposed_window_size(mut self, window_size: u8) -> Self {
218        self.config.proposed_window_size = window_size;
219        self
220    }
221
222    /// Set the response policy for decoded ConfirmedCOVNotifications.
223    pub fn confirmed_cov_notification_ack_policy<F>(mut self, policy: F) -> Self
224    where
225        F: Fn(&ReceivedCOVNotification) -> ConfirmedCOVNotificationResponse + Send + Sync + 'static,
226    {
227        self.options = self
228            .options
229            .with_confirmed_cov_notification_ack_policy(policy);
230        self
231    }
232}