1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// SPDX-License-Identifier: MIT OR Apache-2.0
//!
//! Auto-reconnect configuration for all transports.
//!
//! Use [`.with_reconnect(max_retries, interval)`](crate::ModbusClient) to enable.
use Duration;
/// Reconnect parameters for transport clients.
///
/// # Example
///
/// ```no_run
/// use std::time::Duration;
/// use oms_modbus::*;
///
/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
/// let addr = "127.0.0.1:502".parse()?;
/// let client = tcp::TcpClient::connect(addr).await?
/// .with_reconnect(0, Duration::from_millis(100)); // 0 = infinite retry
/// # Ok(())
/// # }
/// ```
/// Returns `true` if the error indicates a transport-level failure that
/// may be resolved by rebuilding the connection.
///
/// Only **hard transport errors** are retryable:
/// - `Connection` — TCP RST / broken pipe / connection refused
/// - `Serial` — serial port error / device disconnected
///
/// **Not retryable** (retrying won't fix them):
/// - `Timeout` — ambiguous: slow device, wrong slave ID, or silent reject
/// - `Protocol` — CRC mismatch, slave ID mismatch, PDU decode error
/// - `Exception` — Modbus exception response from the server
/// - `Other` — miscellaneous / unknown errors