bacnet-client 0.15.0

BACnet async client: TSM, segmentation, discovery, and service APIs
Documentation
use super::*;

impl<T: TransportPort + 'static> ClientBuilder<T> {
    /// Set the independent event notification broadcast channel capacity.
    pub fn event_channel_capacity(mut self, capacity: usize) -> Self {
        self.options.event_channel_capacity = capacity;
        self
    }

    /// Set the number of APDU retries before a confirmed request times out.
    pub fn apdu_retries(mut self, retries: u8) -> Self {
        self.config.apdu_retries = retries;
        self
    }

    /// Set the least time, in milliseconds, from the latest confirmed
    /// request to a destination finishing to the next being sent (default
    /// 0: no pacing; at most an hour). See
    /// [`ClientConfig::min_request_interval_ms`].
    pub fn min_request_interval_ms(mut self, ms: u64) -> Self {
        self.config.min_request_interval_ms = ms;
        self
    }

    /// Set the maximum number of APDU segments this client accepts.
    ///
    /// Values 0 and 1 fail at build time. Other finite non-rung values are
    /// conservatively rounded down in Confirmed-Request headers.
    pub fn max_segments(mut self, max_segments: Option<u8>) -> Self {
        self.config.max_segments = max_segments;
        self
    }

    /// Set whether this client accepts segmented responses.
    pub fn segmented_response_accepted(mut self, accepted: bool) -> Self {
        self.config.segmented_response_accepted = accepted;
        self
    }

    /// Set the proposed segmented-transfer window size.
    pub fn proposed_window_size(mut self, window_size: u8) -> Self {
        self.config.proposed_window_size = window_size;
        self
    }

    /// Set the response policy for decoded ConfirmedCOVNotifications.
    pub fn confirmed_cov_notification_ack_policy<F>(mut self, policy: F) -> Self
    where
        F: Fn(&ReceivedCOVNotification) -> ConfirmedCOVNotificationResponse + Send + Sync + 'static,
    {
        self.options = self
            .options
            .with_confirmed_cov_notification_ack_policy(policy);
        self
    }
}

impl BipClientBuilder {
    /// Set the independent event notification broadcast channel capacity.
    pub fn event_channel_capacity(mut self, capacity: usize) -> Self {
        self.options.event_channel_capacity = capacity;
        self
    }

    /// Set the number of APDU retries before a confirmed request times out.
    pub fn apdu_retries(mut self, retries: u8) -> Self {
        self.config.apdu_retries = retries;
        self
    }

    /// Set the least time, in milliseconds, from the latest confirmed
    /// request to a destination finishing to the next being sent (default
    /// 0: no pacing; at most an hour). See
    /// [`ClientConfig::min_request_interval_ms`].
    pub fn min_request_interval_ms(mut self, ms: u64) -> Self {
        self.config.min_request_interval_ms = ms;
        self
    }

    /// Set the maximum number of APDU segments this client accepts.
    ///
    /// Values 0 and 1 fail at build time. Other finite non-rung values are
    /// conservatively rounded down in Confirmed-Request headers.
    pub fn max_segments(mut self, max_segments: Option<u8>) -> Self {
        self.config.max_segments = max_segments;
        self
    }

    /// Set whether this client accepts segmented responses.
    pub fn segmented_response_accepted(mut self, accepted: bool) -> Self {
        self.config.segmented_response_accepted = accepted;
        self
    }

    /// Set the proposed segmented-transfer window size.
    pub fn proposed_window_size(mut self, window_size: u8) -> Self {
        self.config.proposed_window_size = window_size;
        self
    }

    /// Set the response policy for decoded ConfirmedCOVNotifications.
    pub fn confirmed_cov_notification_ack_policy<F>(mut self, policy: F) -> Self
    where
        F: Fn(&ReceivedCOVNotification) -> ConfirmedCOVNotificationResponse + Send + Sync + 'static,
    {
        self.options = self
            .options
            .with_confirmed_cov_notification_ack_policy(policy);
        self
    }
}

#[cfg(feature = "ipv6")]
impl Bip6ClientBuilder {
    /// Make the client a foreign device of a B/IPv6 BBMD (Annex U.4.5),
    /// which then carries its broadcasts. Needs
    /// [`Self::device_instance`]; the build fails without one, or when the
    /// registration fails [`Bip6ForeignDeviceConfig::check`].
    pub fn foreign_device(mut self, config: Bip6ForeignDeviceConfig) -> Self {
        self.foreign_device = Some(config);
        self
    }

    /// Set the independent event notification broadcast channel capacity.
    pub fn event_channel_capacity(mut self, capacity: usize) -> Self {
        self.options.event_channel_capacity = capacity;
        self
    }

    /// Set the number of APDU retries before a confirmed request times out.
    pub fn apdu_retries(mut self, retries: u8) -> Self {
        self.config.apdu_retries = retries;
        self
    }

    /// Set the least time, in milliseconds, from the latest confirmed
    /// request to a destination finishing to the next being sent (default
    /// 0: no pacing; at most an hour). See
    /// [`ClientConfig::min_request_interval_ms`].
    pub fn min_request_interval_ms(mut self, ms: u64) -> Self {
        self.config.min_request_interval_ms = ms;
        self
    }

    /// Set the maximum number of APDU segments this client accepts.
    ///
    /// Values 0 and 1 fail at build time. Other finite non-rung values are
    /// conservatively rounded down in Confirmed-Request headers.
    pub fn max_segments(mut self, max_segments: Option<u8>) -> Self {
        self.config.max_segments = max_segments;
        self
    }

    /// Set whether this client accepts segmented responses.
    pub fn segmented_response_accepted(mut self, accepted: bool) -> Self {
        self.config.segmented_response_accepted = accepted;
        self
    }

    /// Set the proposed segmented-transfer window size.
    pub fn proposed_window_size(mut self, window_size: u8) -> Self {
        self.config.proposed_window_size = window_size;
        self
    }

    /// Set the response policy for decoded ConfirmedCOVNotifications.
    pub fn confirmed_cov_notification_ack_policy<F>(mut self, policy: F) -> Self
    where
        F: Fn(&ReceivedCOVNotification) -> ConfirmedCOVNotificationResponse + Send + Sync + 'static,
    {
        self.options = self
            .options
            .with_confirmed_cov_notification_ack_policy(policy);
        self
    }
}

#[cfg(feature = "sc-tls")]
impl ScClientBuilder {
    /// Set the independent event notification broadcast channel capacity.
    pub fn event_channel_capacity(mut self, capacity: usize) -> Self {
        self.options.event_channel_capacity = capacity;
        self
    }

    /// Set the number of APDU retries before a confirmed request times out.
    pub fn apdu_retries(mut self, retries: u8) -> Self {
        self.config.apdu_retries = retries;
        self
    }

    /// Set the least time, in milliseconds, from the latest confirmed
    /// request to a destination finishing to the next being sent (default
    /// 0: no pacing; at most an hour). See
    /// [`ClientConfig::min_request_interval_ms`].
    pub fn min_request_interval_ms(mut self, ms: u64) -> Self {
        self.config.min_request_interval_ms = ms;
        self
    }

    /// Set the maximum number of APDU segments this client accepts.
    ///
    /// Values 0 and 1 fail at build time. Other finite non-rung values are
    /// conservatively rounded down in Confirmed-Request headers.
    pub fn max_segments(mut self, max_segments: Option<u8>) -> Self {
        self.config.max_segments = max_segments;
        self
    }

    /// Set whether this client accepts segmented responses.
    pub fn segmented_response_accepted(mut self, accepted: bool) -> Self {
        self.config.segmented_response_accepted = accepted;
        self
    }

    /// Set the proposed segmented-transfer window size.
    pub fn proposed_window_size(mut self, window_size: u8) -> Self {
        self.config.proposed_window_size = window_size;
        self
    }

    /// Set the response policy for decoded ConfirmedCOVNotifications.
    pub fn confirmed_cov_notification_ack_policy<F>(mut self, policy: F) -> Self
    where
        F: Fn(&ReceivedCOVNotification) -> ConfirmedCOVNotificationResponse + Send + Sync + 'static,
    {
        self.options = self
            .options
            .with_confirmed_cov_notification_ack_policy(policy);
        self
    }
}