snap7-server
In-process S7 PLC simulator for testing and development. Pure Rust — no FFI, no native C dependency. Responds to real S7Comm read/write requests over TCP.
Part of the rs-snap7 workspace.
Use cases
- Unit / integration tests without a physical PLC
- CI pipelines
- Local development
Add to your project
[]
= "0.1"
= { = "1", = ["rt-multi-thread", "macros"] }
Quick start
use ;
use SocketAddr;
async
Ephemeral port (tests)
let cfg = ServerConfig ;
let server = bind.await?;
let addr = server.local_addr?;
spawn;
// connect snap7-client to `addr`
API
| Type | Purpose |
|---|---|
S7Server |
Binds TCP socket, accepts connections |
ServerConfig |
bind_addr + max_connections |
DataStore |
Thread-safe in-memory data block store; read/write by (db, offset) |
Notes
- Implements TPKT / COTP / S7Comm handshake and dispatch.
- Supports multi-item read/write (
ReadVar/WriteVar). - Does not implement S7CommPlus, SZL, or block upload — those return protocol errors.
License
MIT — see LICENSE.