Skip to main content

ClientSession

Struct ClientSession 

Source
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>

Source

pub fn into_stream(self) -> TS

Consumes the session and returns the underlying TCP stream.

§Examples
let tcp_stream = session.into_stream();
Source§

impl<S, TX, TS> ClientSession<'_, S, TX, TS, NoDelay>
where S: Read + Write, TX: OutputPin, TS: Read + Write,

Source

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>
where S: Read + Write, TX: OutputPin, TS: Read + Write, D: DelayNs,

Source

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

Auto Trait Implementations§

§

impl<'b, S, TX, TS, D> Freeze for ClientSession<'b, S, TX, TS, D>
where TS: Freeze,

§

impl<'b, S, TX, TS, D> RefUnwindSafe for ClientSession<'b, S, TX, TS, D>

§

impl<'b, S, TX, TS, D> Send for ClientSession<'b, S, TX, TS, D>
where TS: Send, D: Send, S: Send, TX: Send,

§

impl<'b, S, TX, TS, D> Sync for ClientSession<'b, S, TX, TS, D>
where TS: Sync, D: Sync, S: Sync, TX: Sync,

§

impl<'b, S, TX, TS, D> Unpin for ClientSession<'b, S, TX, TS, D>
where TS: Unpin,

§

impl<'b, S, TX, TS, D> UnsafeUnpin for ClientSession<'b, S, TX, TS, D>
where TS: UnsafeUnpin,

§

impl<'b, S, TX, TS, D = NoDelay> !UnwindSafe for ClientSession<'b, S, TX, TS, D>

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> 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, 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.