Skip to main content

bacnet_client/client/
builder_bip6.rs

1//! The B/IPv6 client builder: [`BACnetClient::bip6_builder`] and
2//! [`Bip6ClientBuilder`].
3use super::*;
4
5#[cfg(feature = "ipv6")]
6impl BACnetClient<Bip6Transport> {
7    /// Create a BIP6-specific builder for BACnet/IPv6 transport.
8    #[cfg_attr(docsrs, doc(cfg(feature = "ipv6")))]
9    pub fn bip6_builder() -> Bip6ClientBuilder {
10        Bip6ClientBuilder {
11            config: ClientConfig::default(),
12            options: ClientOptions::default(),
13            interface: Ipv6Addr::UNSPECIFIED,
14            device_instance: None,
15            foreign_device: None,
16        }
17    }
18}
19
20/// BIP6-specific builder that constructs `Bip6Transport` from IPv6 interface/port/device-instance.
21#[cfg(feature = "ipv6")]
22#[cfg_attr(docsrs, doc(cfg(feature = "ipv6")))]
23pub struct Bip6ClientBuilder {
24    pub(super) config: ClientConfig,
25    pub(super) options: ClientOptions,
26    pub(super) interface: Ipv6Addr,
27    pub(super) device_instance: Option<u32>,
28    pub(super) foreign_device: Option<Bip6ForeignDeviceConfig>,
29}
30
31#[cfg(feature = "ipv6")]
32impl Bip6ClientBuilder {
33    /// Set the local IPv6 interface address.
34    pub fn interface(mut self, ip: Ipv6Addr) -> Self {
35        self.interface = ip;
36        self
37    }
38
39    /// Set the UDP port (0 for ephemeral).
40    pub fn port(mut self, port: u16) -> Self {
41        self.config.port = port;
42        self
43    }
44
45    /// Set the device instance for VMAC derivation (Annex U.5).
46    pub fn device_instance(mut self, instance: u32) -> Self {
47        self.device_instance = Some(instance);
48        self
49    }
50
51    /// Set APDU timeout in milliseconds.
52    pub fn apdu_timeout_ms(mut self, ms: u64) -> Self {
53        self.config.apdu_timeout_ms = ms;
54        self
55    }
56
57    /// Set the maximum APDU length this client accepts.
58    pub fn max_apdu_length(mut self, len: u16) -> Self {
59        self.config.max_apdu_length = len;
60        self
61    }
62
63    /// Set the COV notification broadcast channel capacity.
64    pub fn cov_channel_capacity(mut self, capacity: usize) -> Self {
65        self.options.cov_channel_capacity = capacity;
66        self
67    }
68}