Skip to main content

ProtocolState

Trait ProtocolState 

Source
pub trait ProtocolState<R: RoleT>: Sized + SendData {
    type WireMsg: for<'de> Decode<'de, ()> + Encode<()> + Send;
    type Action: Debug + Send;
    type Out: Debug + PartialEq + Send;
    type Error: Debug + Display + PartialEq + Send;

    // Required methods
    fn init(
        &self,
    ) -> Result<(Outcome<Self::WireMsg, Self::Out, Self::Error>, Self)>;
    fn network(
        &self,
        input: Self::WireMsg,
    ) -> Result<(Outcome<Self::WireMsg, Self::Out, Self::Error>, Self)>;
    fn local(
        &self,
        input: Self::Action,
    ) -> Result<(Outcome<Self::WireMsg, Void, Self::Error>, Self)>;
}
Expand description

This tracks only the network protocol state, reacting to local decisions (Action) or incoming network messages (WireMsg). It may emit information via the Out type.

Required Associated Types§

Required Methods§

Source

fn init(&self) -> Result<(Outcome<Self::WireMsg, Self::Out, Self::Error>, Self)>

Source

fn network( &self, input: Self::WireMsg, ) -> Result<(Outcome<Self::WireMsg, Self::Out, Self::Error>, Self)>

Source

fn local( &self, input: Self::Action, ) -> Result<(Outcome<Self::WireMsg, Void, Self::Error>, Self)>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl ProtocolState<Initiator> for amaru_protocols::blockfetch::State

Source§

type WireMsg = Message

Source§

type Action = InitiatorAction

Source§

type Out = InitiatorResult

Source§

type Error = Void

Source§

impl ProtocolState<Initiator> for amaru_protocols::handshake::State

Source§

type WireMsg = Message<VersionData>

Source§

type Action = InitiatorAction

Source§

type Out = InitiatorResult

Source§

type Error = Void

Source§

impl ProtocolState<Initiator> for amaru_protocols::keepalive::State

Source§

type WireMsg = Message

Source§

type Action = InitiatorAction

Source§

type Out = InitiatorResult

Source§

type Error = Void

Source§

impl ProtocolState<Initiator> for amaru_protocols::tx_submission::State

Source§

type WireMsg = Message

Source§

type Action = InitiatorAction

Source§

type Out = InitiatorResult

Source§

type Error = ProtocolError

Source§

impl ProtocolState<Responder> for amaru_protocols::blockfetch::State

Source§

type WireMsg = Message

Source§

type Action = ResponderAction

Source§

type Out = ResponderResult

Source§

type Error = Void

Source§

impl ProtocolState<Responder> for amaru_protocols::handshake::State

Source§

type WireMsg = Message<VersionData>

Source§

type Action = ResponderAction

Source§

type Out = Proposal

Source§

type Error = Void

Source§

impl ProtocolState<Responder> for amaru_protocols::keepalive::State

Source§

type WireMsg = Message

Source§

type Action = ResponderAction

Source§

type Out = ResponderResult

Source§

type Error = Void

Source§

impl ProtocolState<Responder> for amaru_protocols::tx_submission::State