use std::any::Any;
use async_trait::async_trait;
use puniyu_account::AccountInfo;
use puniyu_adapter_types::{AdapterInfo, SendMsgType};
use puniyu_contact::ContactType;
use puniyu_error::Result;
use puniyu_message::Message;
#[async_trait]
pub trait AdapterApi: Any + Send + Sync {
async fn send_message(
&self,
contact: &ContactType<'_>,
message: &Message,
) -> Result<SendMsgType>;
fn adapter_info(&self) -> AdapterInfo;
fn account_info(&self) -> AccountInfo;
}
impl dyn AdapterApi + 'static {
pub fn as_protocol<T: 'static>(&self) -> Option<&T> {
(self as &dyn Any).downcast_ref::<T>()
}
}