use std::sync::Arc;
use anyhow::Result;
use async_trait::async_trait;
use bytes::Bytes;
#[async_trait]
pub trait Executor: Send + Sync + 'static {
async fn execute(&self, payload: Bytes) -> Result<Bytes> {
self.execute_method("dispatch", payload).await
}
async fn execute_method(&self, method: &str, payload: Bytes) -> Result<Bytes>;
}
#[async_trait]
impl<T: Executor + ?Sized> Executor for Arc<T> {
async fn execute_method(&self, method: &str, payload: Bytes) -> Result<Bytes> {
(**self).execute_method(method, payload).await
}
}