macro-machines

State machine macros with logging and graphviz dotfile generation

Documentation

Current features

Current limitations

Usage

Define and use a minimal state machine:

```rust use macromachines::defmachinedebug; defmachinedebug!{ machine M { STATES [ state S () state T () ] EVENTS [ event A => () ] EXTENDED [] initialstate: S } }

fn main () { use macro_machines::HandleEventException;

let mut m = M::initial(); m.handleevent (EventId::A.into()).unwrap(); asserteq!(m.handle_event (EventId::A.into()), Err (HandleEventException::WrongState)); } ```

Generate a dotfile and write to file:

rust use std::io::Write; use macro_machines::MachineDotfile; let mut f = std::fs::File::create ("minimal.dot").unwrap(); f.write_all (M::dotfile().as_bytes()).unwrap(); drop (f);

Rendered as PNG with $ dot -Tpng minimal.dot > minimal.png:

For examples of more complex state machines, see the ./examples/ directory.

Dependencies