pub struct ModbusTcpServer<S> { /* private fields */ }Expand description
Modbus TCP server that accepts connections and dispatches requests to a ModbusService.
Supports configurable connection limits, PDU size limits, and optional metrics.
Use run to accept connections indefinitely, or
run_until for graceful shutdown.
Implementations§
Source§impl<S: ModbusService> ModbusTcpServer<S>
impl<S: ModbusService> ModbusTcpServer<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 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 the server will accept (default: 253).
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 ModbusTcpServer<S>
impl<S> RefUnwindSafe for ModbusTcpServer<S>where
S: RefUnwindSafe,
impl<S> Send for ModbusTcpServer<S>
impl<S> Sync for ModbusTcpServer<S>
impl<S> Unpin for ModbusTcpServer<S>
impl<S> UnsafeUnpin for ModbusTcpServer<S>
impl<S> UnwindSafe for ModbusTcpServer<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