double_dot_macro/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
pub use double_dot_macro_derive::*;
pub use double_dot_macro_types::*;
pub trait DoubleStates: Send + Sync + Default {
    /// Returns the name of the enum
    fn name(&self) -> &'static str;
    /// Attempts to find a valid linear transition for the current self state.
    /// 
    /// `panics` if no valid linear transition was found for self
    fn linear_transition(&self) -> Self;
    /// Attempts to find a valid arbirary transition for the current self state.
    /// 
    /// `panics` if no valid arbitrary transition was found for self
    fn arbitrary_transition(&self, next_state: &Self) -> Self;
    /// Converts the current self state to a String
    fn to_string(&self) -> String;
    /// Parse the arbitrary transition `String` from `StateFields` into a `Vec<String>`
    fn parse_arbs(&self, arbs: &str) -> Vec<String>;
}

/// Enum for Testing purposes
#[derive(Clone, Eq, PartialEq, Debug, Hash, DoubleStates, Default)]
enum State {
    #[linear(MainMenu)]
    Loading,
    #[arbitrary(Playing, Exit)]
    MainMenu,
    #[default]
    #[linear(Paused)]
    Playing,
    #[arbitrary(MainMenu, Exit)]
    Paused,
    Exit
}