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
use crate::{FsmBackend, FsmBackendImpl, FsmEventQueue, FsmFrontend, FsmResult};
#[cfg(feature="std")]
use crate::FsmEventQueueVec;
pub trait FsmFactory {
type Fsm: FsmBackend;
fn new_with<Q>(context: <Self::Fsm as FsmBackend>::Context, queue: Q) -> FsmResult<FsmFrontend<Self::Fsm, Q>>
where Q: FsmEventQueue<Self::Fsm>
{
let frontend = FsmFrontend {
queue,
backend: FsmBackendImpl::new(context)?
};
Ok(frontend)
}
#[cfg(feature="std")]
fn new(context: <Self::Fsm as FsmBackend>::Context) -> FsmResult<FsmFrontend<Self::Fsm, FsmEventQueueVec<Self::Fsm>>> {
let frontend = FsmFrontend {
queue: FsmEventQueueVec::new(),
backend: FsmBackendImpl::new(context)?
};
Ok(frontend)
}
}