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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//! # Voltage Modbus - High-Performance Industrial Modbus Library
//!
//! **Author:** Evan Liu <liuyifanz.1996@gmail.com>
//! **Version:** 0.4.3
//! **License:** MIT
//!
//! A comprehensive, high-performance Modbus TCP/RTU implementation in pure Rust
//! designed for industrial automation, IoT applications, and smart grid systems.
//!
//! ## Features
//!
//! - **High Performance**: Async/await support with Tokio, stack-allocated PDU
//! - **Complete Protocol Support**: Modbus TCP and RTU protocols
//! - **Memory Safe**: Pure Rust implementation with zero unsafe code
//! - **Zero-Copy Operations**: Optimized for minimal memory allocations
//! - **Industrial Features**: Command batching, read merging, device limits
//! - **Built-in Monitoring**: Comprehensive statistics and metrics
//!
//! ## Supported Function Codes
//!
//! | Code | Function | Client |
//! |------|----------|--------|
//! | 0x01 | Read Coils | ✅ |
//! | 0x02 | Read Discrete Inputs | ✅ |
//! | 0x03 | Read Holding Registers | ✅ |
//! | 0x04 | Read Input Registers | ✅ |
//! | 0x05 | Write Single Coil | ✅ |
//! | 0x06 | Write Single Register | ✅ |
//! | 0x0F | Write Multiple Coils | ✅ |
//! | 0x10 | Write Multiple Registers | ✅ |
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use voltage_modbus::{ModbusTcpClient, ModbusClient, ModbusResult};
//! use std::time::Duration;
//!
//! #[tokio::main]
//! async fn main() -> ModbusResult<()> {
//! // Connect to Modbus TCP server
//! let mut client = ModbusTcpClient::from_address("127.0.0.1:502", Duration::from_secs(5)).await?;
//!
//! // Read holding registers
//! let values = client.read_03(1, 0, 10).await?;
//! println!("Read registers: {:?}", values);
//!
//! // Write single register
//! client.write_06(1, 100, 0x1234).await?;
//!
//! client.close().await?;
//! Ok(())
//! }
//! ```
// ============================================================================
// Core modules
// ============================================================================
/// Core error types and result handling
/// Modbus protocol constants based on official specification
/// High-performance PDU with stack-allocated fixed array
/// Modbus protocol definitions and message handling
/// Network transport layer for TCP and RTU communication
/// Modbus client implementations
/// Utility functions and performance monitoring
/// Logging system for the library
// ============================================================================
// Industrial enhancement modules (Phase 3)
// ============================================================================
/// Industrial data value types for Modbus
/// Byte order handling for multi-register data types
/// Encoding and decoding of Modbus data with byte order support
/// Command batching for optimized write operations
/// Device-specific protocol limits configuration
// ============================================================================
// Re-exports for convenience
// ============================================================================
// === Async runtime (users can use voltage_modbus::tokio) ===
pub use tokio;
// === Core client API ===
pub use ;
// === Error handling ===
pub use ;
// === Core types ===
pub use ByteOrder;
pub use ;
pub use ModbusValue;
// === Industrial features ===
pub use ;
pub use ModbusCodec;
pub use DeviceLimits;
// === Monitoring ===
pub use ;
// === Packet Callback (for real packet logging) ===
pub use ;
pub use PerformanceMetrics;
// === Protocol limits (commonly needed constants) ===
pub use ;
// === Logging ===
pub use ;
// === PDU (advanced usage) ===
pub use ;
// === Hidden but preserved (backward compatibility) ===
pub use ;
pub use ;
pub use ;
pub use ;
pub use OperationTimer;
pub use ModbusRtuClient;
pub use RtuTransport;
/// Default timeout for operations (5 seconds)
pub const DEFAULT_TIMEOUT_MS: u64 = 5000;
/// Modbus TCP default port
pub const DEFAULT_TCP_PORT: u16 = 502;
/// Library version
pub const VERSION: &str = env!;
/// Get library information