pub struct ClientSession<'b, S, TX, TS, D = NoDelay> { /* private fields */ }Expand description
An active Modbus RTU → TCP client session.
Returned by Client::connect. Mutably borrows the
client for its lifetime, preventing a second session from being opened until
this one is finished.
Drive the session by calling next in a loop.
Implementations§
Source§impl<'b, S, TX, TS, D> ClientSession<'b, S, TX, TS, D>
impl<'b, S, TX, TS, D> ClientSession<'b, S, TX, TS, D>
Sourcepub fn into_stream(self) -> TS
pub fn into_stream(self) -> TS
Source§impl<S, TX, TS> ClientSession<'_, S, TX, TS, NoDelay>
impl<S, TX, TS> ClientSession<'_, S, TX, TS, NoDelay>
Sourcepub async fn next(
&mut self,
) -> Result<BridgeEvent, BridgeError<S::Error, TS::Error>>
pub async fn next( &mut self, ) -> Result<BridgeEvent, BridgeError<S::Error, TS::Error>>
Drives one complete Modbus request/response cycle asynchronously.
Reads an RTU request from the serial port, forwards it to the upstream Modbus TCP server, and returns the response to the RTU master.
§Errors
Returns BridgeError::RtuClosed when the
RTU master closes the connection cleanly.
Source§impl<S, TX, TS, D> ClientSession<'_, S, TX, TS, D>
impl<S, TX, TS, D> ClientSession<'_, S, TX, TS, D>
Sourcepub async fn next(
&mut self,
) -> Result<BridgeEvent, BridgeError<S::Error, TS::Error>>
pub async fn next( &mut self, ) -> Result<BridgeEvent, BridgeError<S::Error, TS::Error>>
Drives one complete Modbus request/response cycle asynchronously, with timeouts.
Reads an RTU request from the serial port, forwards it to the upstream
Modbus TCP server, and returns the response to the RTU master.
Applies rtu_timeout_ms around the RTU listen and tcp_timeout_ms
around the TCP response.
§Errors
BridgeError::RtuClosed— RTU master sent EOF (normal disconnect).BridgeError::RtuIo— Serial port I/O error.BridgeError::RtuCrcMismatch— RTU request failed CRC-16 check.BridgeError::TcpClosed— Upstream TCP server closed the connection.BridgeError::TcpIo— TCP stream I/O error.BridgeError::BufferOverflow— Frame exceeded internal buffer capacity.BridgeError::Timeout— An I/O operation did not complete within the configured deadline.