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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use crate::lib::*;
use crate::{FsmBackend, fsm::EventContext};
use super::{FsmQueueMock, FsmStateBuilder};
pub struct FsmEventBuilderState<'a, TFsm, TContext, TEvent, TState> {
pub (crate) _state_builder: &'a FsmStateBuilder<TFsm, TContext, TState>,
pub (crate) _event: PhantomData<TEvent>
}
impl<'a, TFsm, TContext, TEvent, TState> FsmEventBuilderState<'a, TFsm, TContext, TEvent, TState> {
pub fn internal_transition<'b>(&'b self) -> FsmEventBuilderTransition<'b, TFsm, TContext, TEvent, TState> {
FsmEventBuilderTransition {
_state_event_builder: self
}
}
pub fn self_transition<'b>(&'b self) -> FsmEventBuilderTransition<'b, TFsm, TContext, TEvent, TState> {
FsmEventBuilderTransition {
_state_event_builder: self
}
}
pub fn transition_to<'b, TStateTo>(&'b self) -> FsmEventBuilderTransitionFull<'b, TFsm, TContext, TEvent, TState, TStateTo> {
FsmEventBuilderTransitionFull {
_transition_from: self,
_state_to: PhantomData::default()
}
}
}
pub struct FsmEventBuilderTransition<'a, TFsm, TContext, TEvent, TState> {
_state_event_builder: &'a FsmEventBuilderState<'a, TFsm, TContext, TEvent, TState>
}
impl<'a, TFsm, TContext, TEvent, TState> FsmEventBuilderTransition<'a, TFsm, TContext, TEvent, TState>
where TFsm: FsmBackend
{
pub fn action<TAction: Fn(&TEvent, &mut EventContext<'a, TFsm, FsmQueueMock<TFsm>>, &mut TState)>(&mut self, _action: TAction) -> &mut Self {
self
}
pub fn guard<TGuard: Fn(&TEvent, &EventContext<'a, TFsm, FsmQueueMock<TFsm>>, &<TFsm as FsmBackend>::States) -> bool>(&mut self, _guard: TGuard) -> &mut Self {
self
}
pub fn with_transition_ty<TTransition>(&mut self) -> &mut Self {
self
}
}
pub struct FsmEventBuilderTransitionFull<'a, TFsm, TContext, TEvent, TStateFrom, TStateTo> {
_transition_from: &'a FsmEventBuilderState<'a, TFsm, TContext, TEvent, TStateFrom>,
_state_to: PhantomData<TStateTo>
}
impl<'a, TFsm, TContext, TEvent, TStateFrom, TStateTo> FsmEventBuilderTransitionFull<'a, TFsm, TContext, TEvent, TStateFrom, TStateTo>
where TFsm: FsmBackend
{
pub fn action<TAction: Fn(&TEvent, &mut EventContext<'a, TFsm, FsmQueueMock<TFsm>>, &mut TStateFrom, &mut TStateTo)>(&mut self, _action: TAction) -> &mut Self {
self
}
pub fn guard<TGuard: Fn(&TEvent, &EventContext<'a, TFsm, FsmQueueMock<TFsm>>, &<TFsm as FsmBackend>::States) -> bool>(&mut self, _guard: TGuard) -> &mut Self {
self
}
pub fn with_transition_ty<TTransition>(&mut self) -> &mut Self {
self
}
}