mbus-network
mbus-network is a helper crate for modbus-rs.
It provides a standard Modbus TCP transport implementation that plugs into the
shared transport abstractions from mbus-core.
If you want a single top-level API, use modbus-rs.
If you need direct transport-level control, use mbus-network directly.
Helper Crate Role
mbus-network is transport-focused and intentionally small:
- Implements
Transportfrommbus-coreusingstd::net::TcpStream. - Handles connection setup, send, receive, and disconnect for Modbus TCP.
- Maps I/O failures into
TransportError.
This crate does not implement request orchestration or function-code services.
That logic is provided by mbus-client.
What Is Included
StdTcpTransport: concrete transport implementation for Modbus TCP.- Timeout setup from
ModbusTcpConfig. - Basic DNS resolution and connect flow.
- Non-blocking receive pass that returns currently available bytes.
Public API Surface
The crate currently re-exports:
StdTcpTransport
from:
management::std_transport
Usage
1) Add dependencies
[]
= "0.6.0"
2) Create TCP config and connect transport
use ;
Configuration Notes
- Use
ModbusConfig::Tcp(...)when callingconnect. Passing a serial config returns a transport configuration error. connection_timeout_msandresponse_timeout_msfromModbusTcpConfigare applied to the underlying stream.
Logging
mbus-network supports optional logging via the log facade.
- Enable feature:
logging - This only emits through the facade; your application provides a logger backend.
Example dependency setup:
[]
= { = "0.6.0", = ["logging"] }
= "0.11"
Receive Behavior
recv()returns bytes currently available from the socket.- A full Modbus ADU may arrive in multiple chunks.
- Higher-level logic should buffer and frame messages as needed.
Typical Integration Pattern
In most applications, mbus-network is used together with mbus-client:
- Build
ModbusConfig::Tcp(...). - Instantiate
StdTcpTransport. - Pass transport into
ClientServicesfrommbus-client. - Use client services to issue function-code operations.
License
Copyright (C) 2025 Raghava Challari
This project is currently licensed under GNU GPL v3.0. See LICENSE for details.
This crate is licensed under GPLv3. If you require a commercial license to use this crate in a proprietary project, please contact ch.raghava44@gmail.com to purchase a license.
Contact
For questions or support:
- Name: Raghava Ch
- Email: ch.raghava44@gmail.com