pub struct ModbusTcpTransport { /* private fields */ }Expand description
Modbus TCP client transport implementing the DataLink trait.
Uses MBAP framing with auto-incrementing transaction IDs. The transport
is internally mutex-protected, so it can be shared behind an Arc.
Implementations§
Source§impl ModbusTcpTransport
impl ModbusTcpTransport
Sourcepub async fn connect<A: ToSocketAddrs>(addr: A) -> Result<Self, DataLinkError>
pub async fn connect<A: ToSocketAddrs>(addr: A) -> Result<Self, DataLinkError>
Connect to a Modbus TCP device (e.g. "192.168.1.10:502").
Sourcepub fn from_stream(stream: TcpStream) -> Self
pub fn from_stream(stream: TcpStream) -> Self
Wrap an existing TcpStream as a Modbus TCP transport.
Trait Implementations§
Source§impl DataLink for ModbusTcpTransport
impl DataLink for ModbusTcpTransport
Source§fn reconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), DataLinkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), DataLinkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Attempt to re-establish the underlying connection. Read more
Source§fn exchange<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
unit_id: UnitId,
request_pdu: &'life1 [u8],
response_pdu: &'life2 mut [u8],
) -> Pin<Box<dyn Future<Output = Result<usize, DataLinkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn exchange<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
unit_id: UnitId,
request_pdu: &'life1 [u8],
response_pdu: &'life2 mut [u8],
) -> Pin<Box<dyn Future<Output = Result<usize, DataLinkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Send a request PDU to a unit and write the response PDU into
response_pdu. Read moreSource§fn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Check if the transport is connected. Read more
Auto Trait Implementations§
impl Freeze for ModbusTcpTransport
impl !RefUnwindSafe for ModbusTcpTransport
impl Send for ModbusTcpTransport
impl Sync for ModbusTcpTransport
impl Unpin for ModbusTcpTransport
impl UnsafeUnpin for ModbusTcpTransport
impl !UnwindSafe for ModbusTcpTransport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more