Skip to main content

ClientOptions

Struct ClientOptions 

Source
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

Source

pub fn new() -> Self

Create a new ClientOptions with default values (1s timeout, 3.5T @ 9600 baud).

Source

pub fn timeout(&self) -> Duration

Current request timeout.

Source

pub fn reconnect(&self) -> Option<&ReconnectConfig>

Configured reconnect parameters, if any.

Source

pub fn bus_timing(&self) -> Option<&Arc<BusTiming>>

Configured bus timing, if any.

Source

pub fn tap(&self) -> Option<&Arc<dyn WireTap>>

Attached WireTap, if any.

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Set the per-request timeout. Applied to both send and receive.

Source

pub fn with_tap(self, tap: Arc<dyn WireTap>) -> Self

Attach any WireTapBusCapture, FileRecorder, or custom.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> ClientOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for ClientOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.