Trait Protocol

Source
pub trait Protocol {
    type Output;

    // Required methods
    fn poke(&mut self) -> Result<Action<Self::Output>, ProtocolError>;
    fn message(&mut self, from: Participant, data: MessageData);
}
Expand description

A trait for protocols.

Basically, this represents a struct for the behavior of a single participant in a protocol. The idea is that the computation of that participant is driven mainly by receiving messages from other participants.

Required Associated Types§

Required Methods§

Source

fn poke(&mut self) -> Result<Action<Self::Output>, ProtocolError>

Poke the protocol, receiving a new action.

The idea is that the protocol should be poked until it returns an error, or it returns an action with a return value, or it returns a wait action.

Upon returning a wait action, that protocol will not advance any further until a new message arrives.

Source

fn message(&mut self, from: Participant, data: MessageData)

Inform the protocol of a new message.

Implementors§