pub struct ClientOptions { /* private fields */ }Expand description
Common options for all Modbus clients — timeout, WireTap, reconnect, timing.
§Examples
use oms_modbus::*;
use std::time::Duration;
let opts = ClientOptions::default()
.with_timeout(Duration::from_secs(3))
.with_tap(std::sync::Arc::new(BusCapture::unbounded()))
.with_reconnect(3, Duration::from_millis(100));
let client = rtu::with_options(port, opts);Implementations§
Source§impl ClientOptions
impl ClientOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ClientOptions with default values (1s timeout, 3.5T @ 9600 baud).
Sourcepub fn reconnect(&self) -> Option<&ReconnectConfig>
pub fn reconnect(&self) -> Option<&ReconnectConfig>
Configured reconnect parameters, if any.
Sourcepub fn bus_timing(&self) -> Option<&Arc<BusTiming>>
pub fn bus_timing(&self) -> Option<&Arc<BusTiming>>
Configured bus timing, if any.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set the per-request timeout. Applied to both send and receive.
Sourcepub fn with_tap(self, tap: Arc<dyn WireTap>) -> Self
pub fn with_tap(self, tap: Arc<dyn WireTap>) -> Self
Attach any WireTap — BusCapture, FileRecorder, or custom.
Sourcepub fn with_reconnect(self, max_retries: u32, interval: Duration) -> Self
pub fn with_reconnect(self, max_retries: u32, interval: Duration) -> Self
Enable auto-reconnect on transport errors with a fixed retry interval.
max_retries = 0 means infinite.
Sourcepub fn with_bus_timing(self, timing: BusTiming) -> Self
pub fn with_bus_timing(self, timing: BusTiming) -> Self
Enforce minimum spacing between Modbus frames.
Prevents sending too fast on RS-485 buses where low-performance
slave devices may crash. Use BusTiming::rtu_35t for standard
RTU/ASCII timing, or BusTiming::custom for a fixed delay.
Sourcepub fn with_data_channel_capacity(self, bytes: usize) -> Self
pub fn with_data_channel_capacity(self, bytes: usize) -> Self
Set the SniffIo data channel capacity in bytes (default: 1 MB).
Only meaningful when a tap is attached. The data channel buffers
bytes between the background reader and poll_read. When full,
oldest chunks are evicted.
Sourcepub fn with_tap_channel_capacity(self, bytes: usize) -> Self
pub fn with_tap_channel_capacity(self, bytes: usize) -> Self
Set the SniffIo tap channel capacity in bytes (default: 256 KB).
Only meaningful when a tap is attached. The tap channel buffers bytes for the tap forwarder task. When full, oldest chunks are evicted.
Trait Implementations§
Source§impl Clone for ClientOptions
impl Clone for ClientOptions
Source§fn clone(&self) -> ClientOptions
fn clone(&self) -> ClientOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more