Skip to main content

ProtocolStateMachine

Trait ProtocolStateMachine 

Source
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§

Source

fn protocol_name(&self) -> &str

Get the protocol name.

Source

fn role(&self) -> &RoleName

Get the current role.

Source

fn blocked_on(&self) -> BlockedOn<Self::Label>

Get what the state machine is currently blocked on.

Source

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.

Source

fn checkpoint(&self) -> Result<Checkpoint, CheckpointError>

Create a checkpoint of the current state.

Source

fn restore(&mut self, checkpoint: &Checkpoint) -> Result<(), CheckpointError>

Restore state from a checkpoint.

Source

fn sequence(&self) -> u64

Get the current sequence number.

Provided Methods§

Source

fn is_complete(&self) -> bool

Check if the protocol has completed.

Implementors§