#hardware #scada #secop #sample-environment

macro secop-derive

A Rust framework for a hardware server speaking the SECoP protocol (derive package)

1 unstable release

0.1.3 Jun 20, 2022

#38 in #scada

30 downloads per month
Used in 3 crates (2 directly)


544 lines


A Rust framework and demo devices for a hardware server speaking the SECoP protocol.


Install the Rust toolchain, currently the nightly channel is required.

Debug mode (faster compilation): cargo run -- test.cfg.

Release mode (optimized for speed): cargo run --release -- test.cfg.


The code is (currently) split into four crates:

  • secop-core provides the meat of the framework, and server implementation
  • secop-derive (which has to be separate as a proc-macro crate) helps the framework by auto-generating interface boilerplate
  • secop-modules contains concrete modules
  • secop just has the main executable(s)


Derive support for secop modules

There are two auto-derive traits implemented here:

  • ModuleBase is a complete implementation of the guts of a module. It provides an easy DSL to add parameters and commands, and translates that into the respective case handling in the methods that implement the basic SECoP actions like change and do.

    It also provides automatic translation and verification between JSON payloads and Rust data for parameter and argument types.

  • TypeDesc can be derived for enums and structs, and provides a type- safe way to declare parameters and commands with enum and struct datatypes.


~44K SLoC