pub struct TurnMachine<M: TurnProtocol = UnitTurnProtocol> { /* private fields */ }Expand description
Sans-IO state machine for a single session run (multi-turn).
Implementations§
Source§impl<M: TurnProtocol> TurnMachine<M>
impl<M: TurnProtocol> TurnMachine<M>
Sourcepub fn new(
config: TurnMachineConfig<M>,
messages: Vec<Message>,
events: Arc<Vec<SessionEventRecord<M::Event>>>,
protocol_run_offset: usize,
) -> Self
pub fn new( config: TurnMachineConfig<M>, messages: Vec<Message>, events: Arc<Vec<SessionEventRecord<M::Event>>>, protocol_run_offset: usize, ) -> Self
Create a new machine in PrepareIteration state.
pub fn messages(&self) -> Arc<Vec<Message>> ⓘ
pub fn events(&self) -> Arc<Vec<SessionEventRecord<M::Event>>> ⓘ
pub fn message_sequence(&self) -> MessageSequence
pub fn protocol_iteration(&self) -> usize
pub fn checkpoint(&self) -> TurnCheckpoint<M>
pub fn restore_from_checkpoint( config: TurnMachineConfig<M>, checkpoint: TurnCheckpoint<M>, ) -> Self
pub fn fail_turn(&mut self, event: SessionEvent)
pub fn finish_with_outcome(&mut self, outcome: TurnOutcome)
Sourcepub fn poll_effect(&mut self) -> Option<Effect<M>>
pub fn poll_effect(&mut self) -> Option<Effect<M>>
Drain the next pending effect. Returns None when the host must call
handle_response() before more effects become available.
pub fn apply_actions(&mut self, actions: Vec<DriverAction<M>>)
Sourcepub fn handle_response(&mut self, response: Response)
pub fn handle_response(&mut self, response: Response)
Feed a response to a previously emitted effect.
Auto Trait Implementations§
impl<M = UnitTurnProtocol> !Freeze for TurnMachine<M>
impl<M = UnitTurnProtocol> !RefUnwindSafe for TurnMachine<M>
impl<M = UnitTurnProtocol> !UnwindSafe for TurnMachine<M>
impl<M> Send for TurnMachine<M>
impl<M> Sync for TurnMachine<M>
impl<M> Unpin for TurnMachine<M>where
<M as TurnProtocol>::Termination: Unpin,
<M as TurnProtocol>::DriverState: Unpin,
<M as TurnProtocol>::Event: Unpin,
impl<M> UnsafeUnpin for TurnMachine<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more