rogue_runtime/traits/message_handler.rs
1use crate::serde::Serialize;
2use crate::serde::de::DeserializeOwned;
3
4use crate::{InventoryItemProvider, TypeInfo, async_trait};
5
6/// Trait for messages that can be handled by the runtime
7#[async_trait]
8pub trait MessageHandler: InventoryItemProvider + Send + Sync {
9 type Input: TypeInfo + DeserializeOwned + Serialize + Send + Sync;
10 type Output: TypeInfo + DeserializeOwned + Serialize + Send + Sync;
11
12 /// Handle the message
13 async fn handle(data: Self::Input) -> Result<Self::Output, String>;
14}