pub struct ModbusRtuOverTcpServer<S> { /* private fields */ }Expand description
Modbus RTU-over-TCP server that accepts TCP connections carrying RTU-framed requests.
This is useful for RTU gateways or testing environments where RTU framing is tunnelled over a TCP socket.
Implementations§
Source§impl<S: ModbusService> ModbusRtuOverTcpServer<S>
impl<S: ModbusService> ModbusRtuOverTcpServer<S>
Sourcepub async fn bind<A: ToSocketAddrs>(
addr: A,
service: S,
) -> Result<Self, DataLinkError>
pub async fn bind<A: ToSocketAddrs>( addr: A, service: S, ) -> Result<Self, DataLinkError>
Bind to a TCP address and create a new RTU-over-TCP server.
Sourcepub fn from_listener(listener: TcpListener, service: S) -> Self
pub fn from_listener(listener: TcpListener, service: S) -> Self
Create a server from an existing TcpListener.
Sourcepub fn local_addr(&self) -> Result<SocketAddr, DataLinkError>
pub fn local_addr(&self) -> Result<SocketAddr, DataLinkError>
Return the local address the server is bound to.
Sourcepub fn with_max_pdu_len(self, max_pdu_len: usize) -> Self
pub fn with_max_pdu_len(self, max_pdu_len: usize) -> Self
Set the maximum PDU length (default: 253).
Sourcepub fn with_max_frame_len(self, max_frame_len: usize) -> Self
pub fn with_max_frame_len(self, max_frame_len: usize) -> Self
Set the maximum RTU frame length including address + CRC (default: 256).
Sourcepub fn with_max_connections(self, max_connections: usize) -> Self
pub fn with_max_connections(self, max_connections: usize) -> Self
Set the maximum number of concurrent client connections (default: 256).
Sourcepub async fn run(self) -> Result<(), DataLinkError>
pub async fn run(self) -> Result<(), DataLinkError>
Accept connections and serve requests indefinitely.
Auto Trait Implementations§
impl<S> !Freeze for ModbusRtuOverTcpServer<S>
impl<S> RefUnwindSafe for ModbusRtuOverTcpServer<S>where
S: RefUnwindSafe,
impl<S> Send for ModbusRtuOverTcpServer<S>
impl<S> Sync for ModbusRtuOverTcpServer<S>
impl<S> Unpin for ModbusRtuOverTcpServer<S>
impl<S> UnsafeUnpin for ModbusRtuOverTcpServer<S>
impl<S> UnwindSafe for ModbusRtuOverTcpServer<S>where
S: RefUnwindSafe,
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