| ▲ | vatsachak a day ago | ||||||||||||||||
In the type state pattern you would have something like this pub trait ValidState {} struct StateMachine<'a, T> where
{untyped: &'a mut UntypedStateMachine, _marker: PhantomData<T> } fn reserve_right<'a>(state: StateMachine<'a, Begin>) -> StateMachine<'a, Reserved> fn query<'a>(state: StateMachine<'a, Reserved>) -> StateMachine<'a, Queried> fn record<'a>(state: StateMachine<'a, Queried>) -> StateMachine<'a, Recorded> | |||||||||||||||||
| ▲ | throwaway894345 14 hours ago | parent [-] | ||||||||||||||||
How do you model cases where the reservation fails, where the inventory operation is already complete, etc? Basically conditional transitions based on some data received? Also, where does the actual I/O happen? Presumably there is some shell that drives the state machine that does the I/O before or after executing the transition? | |||||||||||||||||
| |||||||||||||||||