statemachine 0.1.0

Provides utilities for working with statemachines.
Documentation
  • Coverage
  • 100%
    1 out of 1 items documented0 out of 0 items with examples
  • Size
  • Source code size: 3.7 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.03 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • FloorIsJava/statemachine
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • RealFloorIsJava

statemachine

A Rust crate providing utilities for working with state machines. Documentation is available on docs.rs.

NOTE: In the future, this module will contain more machines and automata. Currently it only adds a way to define statemachines.

Usage

Add this to your Cargo.toml:

[dependencies]
statemachine = "0.1"

Getting Started

use statemachine::statemachine;

statemachine! {
    #[derive(Default)]
    struct Foo {}

    enum FooState consumes [char] from Start accepts [NonEmpty];

    Start => {
        char match _ => NonEmpty
    },

    NonEmpty => {
        _ => NonEmpty
    }
}

fn main() {
    let mut foo: Foo = Default::default();
    assert!(!foo.is_accepting());
    foo.consume('a');
    assert!(foo.is_accepting());
    foo.consume('b');
    assert!(foo.is_accepting());
    foo.consume('c');
    assert!(foo.is_accepting());
}

License

This crate is published under the terms of the MIT license. See the LICENSE file for details.