pub trait ProtocolStateMachine: Send {
type Label: LabelId;
// Required methods
fn protocol_name(&self) -> &str;
fn role(&self) -> &RoleName;
fn blocked_on(&self) -> BlockedOn<Self::Label>;
fn step(
&mut self,
input: StepInput<Self::Label>,
) -> Result<StepOutput<Self::Label>, ChoreographyError>;
fn checkpoint(&self) -> Result<Checkpoint, CheckpointError>;
fn restore(
&mut self,
checkpoint: &Checkpoint,
) -> Result<(), CheckpointError>;
fn sequence(&self) -> u64;
// Provided method
fn is_complete(&self) -> bool { ... }
}Expand description
Trait for protocol state machines that can be stepped through.
This trait is the core abstraction for simulation. It allows external simulators to control protocol execution step-by-step.
Required Associated Types§
Required Methods§
Sourcefn protocol_name(&self) -> &str
fn protocol_name(&self) -> &str
Get the protocol name.
Sourcefn blocked_on(&self) -> BlockedOn<Self::Label>
fn blocked_on(&self) -> BlockedOn<Self::Label>
Get what the state machine is currently blocked on.
Sourcefn step(
&mut self,
input: StepInput<Self::Label>,
) -> Result<StepOutput<Self::Label>, ChoreographyError>
fn step( &mut self, input: StepInput<Self::Label>, ) -> Result<StepOutput<Self::Label>, ChoreographyError>
Attempt to advance the state machine with the given input.
Returns Ok(StepOutput) if the step succeeded, or an error
if the input was invalid for the current state.
Sourcefn checkpoint(&self) -> Result<Checkpoint, CheckpointError>
fn checkpoint(&self) -> Result<Checkpoint, CheckpointError>
Create a checkpoint of the current state.
Sourcefn restore(&mut self, checkpoint: &Checkpoint) -> Result<(), CheckpointError>
fn restore(&mut self, checkpoint: &Checkpoint) -> Result<(), CheckpointError>
Restore state from a checkpoint.
Provided Methods§
Sourcefn is_complete(&self) -> bool
fn is_complete(&self) -> bool
Check if the protocol has completed.