waynest/client/mod.rs
1mod error;
2pub mod protocol;
3
4use std::{any::Any, sync::Arc};
5
6use async_trait::async_trait;
7pub use error::{Error, Result};
8
9use crate::wire::{Message, ObjectId, Socket};
10
11#[async_trait]
12pub trait Dispatcher: Any + Send + Sync + 'static {
13 // necessary for trait upcasting
14 fn as_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync + 'static>;
15
16 async fn dispatch(
17 &self,
18 socket: &mut Socket,
19 sender_id: ObjectId,
20 message: &mut Message,
21 ) -> Result<()>;
22}