Skip to main content

double_dot_macro/
lib.rs

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