secop_derive/
lib.rs

1// -----------------------------------------------------------------------------
2// Rust SECoP playground
3//
4// This program is free software; you can redistribute it and/or modify it under
5// the terms of the GNU General Public License as published by the Free Software
6// Foundation; either version 2 of the License, or (at your option) any later
7// version.
8//
9// This program is distributed in the hope that it will be useful, but WITHOUT
10// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11// FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
12// details.
13//
14// You should have received a copy of the GNU General Public License along with
15// this program; if not, write to the Free Software Foundation, Inc.,
16// 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17//
18// Module authors:
19//   Georg Brandl <g.brandl@fz-juelich.de>
20//
21// -----------------------------------------------------------------------------
22//
23//! # Derive support for secop modules
24//!
25//! There are two auto-derive traits implemented here:
26//!
27//! * `ModuleBase` is a complete implementation of the guts of a module.  It
28//!   provides an easy DSL to add parameters and commands, and translates that
29//!   into the respective case handling in the methods that implement the
30//!   basic SECoP actions like `change` and `do`.
31//!
32//!   It also provides automatic translation and verification between JSON
33//!   payloads and Rust data for parameter and argument types.
34//!
35//! * `TypeDesc` can be derived for enums and structs, and provides a type-
36//!   safe way to declare parameters and commands with enum and struct
37//!   datatypes.
38
39mod module;
40mod typedesc;
41
42use synstructure::decl_derive;
43
44decl_derive!([ModuleBase, attributes(param, command)] => crate::module::derive_module);
45decl_derive!([TypeDesc, attributes(datatype)] => crate::typedesc::derive_typedesc);