pub struct ExclusiveExecutor<M: Machine> { /* private fields */ }Expand description
Allocation-free execution of an affine machine through exclusive access.
A turn installs the poisoned state before calling Machine::step. If the
transition unwinds, no machine remains accessible and all future inputs are
rejected intact. Output consumption after a successful turn is outside this
poison boundary.
Implementations§
Source§impl<M: Machine> ExclusiveExecutor<M>
impl<M: Machine> ExclusiveExecutor<M>
Sourcepub fn turn(
&mut self,
input: M::Input,
) -> Result<M::Output, PoisonedInput<M::Input>>
pub fn turn( &mut self, input: M::Input, ) -> Result<M::Output, PoisonedInput<M::Input>>
Execute one immediate turn and install its successor.
§Errors
Returns the supplied input without accepting it if an earlier transition poisoned the executor. An input consumed by a transition that panics is not recoverable.
§Panics
Propagates a panic from Machine::step after poisoning the executor.
Sourcepub const fn state(&self) -> ExclusiveState
pub const fn state(&self) -> ExclusiveState
Report whether a successor machine remains available.
Sourcepub const fn machine(&self) -> Option<&M>
pub const fn machine(&self) -> Option<&M>
Borrow the current successor machine, or None if it was poisoned.
Sourcepub fn into_inner(self) -> Result<M, ExclusivePoisoned>
pub fn into_inner(self) -> Result<M, ExclusivePoisoned>
Recover the current successor machine.
§Errors
Returns ExclusivePoisoned if a panicking transition consumed it.