mck/traits/
concr.rs

1use std::fmt::Debug;
2use std::hash::Hash;
3
4use super::{abstr, misc::MachineMisc};
5
6pub trait Input: Debug + PartialEq + Eq + Hash + Clone + Send + Sync {}
7
8impl<T: Debug + PartialEq + Eq + Hash + Clone + Send + Sync> Input for T {}
9
10pub trait Param: Debug + PartialEq + Eq + Hash + Clone + Send + Sync {}
11
12impl<T: Debug + PartialEq + Eq + Hash + Clone + Send + Sync> Param for T {}
13
14pub trait State {}
15
16impl<T: Debug + PartialEq + Eq + Hash + Clone + Send + Sync> State for T {}
17
18pub trait Machine
19where
20    Self: Sized + 'static + Send + Sync,
21{
22    /**
23     * Machine input.
24     */
25    type Input: Input;
26
27    /**
28     * Machine parameter.
29     */
30    type Param: Param;
31
32    /**
33     * Machine state.
34     */
35    type State: State;
36
37    /**
38     * Creates an initial state from an initial input.
39     */
40    #[must_use]
41    fn init(&self, input: &Self::Input, param: &Self::Param) -> Self::State;
42
43    /**
44     * Creates next state from current state, given the input.
45     */
46    #[must_use]
47    fn next(&self, state: &Self::State, input: &Self::Input, param: &Self::Param) -> Self::State;
48}
49
50pub trait Test {
51    fn into_bool(self) -> bool;
52}
53
54pub trait FullMachine: Machine + MachineMisc {
55    type Abstr: abstr::Machine<Self>;
56}
57
58pub trait IntoMck {
59    type Type;
60    #[must_use]
61    fn into_mck(self) -> Self::Type;
62}