mai_sdk_core/handler.rs
1use crate::network::NetworkMessage;
2use anyhow::Result;
3
4/// Handler
5/// Implement this trait as part of the handling logic for incoming network messages
6/// This is meant to be used as a "middleware" for the node to consume and create functionality
7pub trait Handler {
8 fn handle_message(
9 &self,
10 message: NetworkMessage,
11 ) -> impl std::future::Future<Output = Result<NetworkMessage>> + Send;
12}
13
14/// Startable
15/// Implement this trait to allow the node to start the handler
16pub trait Startable {
17 fn start(&self) -> impl std::future::Future<Output = Result<()>> + Send;
18}