Trait HandleMessage

Source
pub trait HandleMessage {
    type Message: Serialize + DeserializeOwned + Send + Sync + 'static;
    type Error: Error + 'static;

    // Required method
    fn handle_message(
        &mut self,
        msg: Envelope<Self::Message>,
        outbound_msg_tx: Sender<Envelope<Self::Message>>,
    ) -> Result<(), Self::Error>;
}
Expand description

A single node should be able to handle messages of a given type, and return an error if something goes wrong.

Required Associated Types§

Source

type Message: Serialize + DeserializeOwned + Send + Sync + 'static

The type of message this node can handle. Typically, this is a discriminated union of all rpc requests and response types that can be communicated by client-node or node-node.

Source

type Error: Error + 'static

Any custom error to panic with and stop the maelstrom runtime early to indicate a problem with the node.

Required Methods§

Source

fn handle_message( &mut self, msg: Envelope<Self::Message>, outbound_msg_tx: Sender<Envelope<Self::Message>>, ) -> Result<(), Self::Error>

Implementors§