feat: implement asynchronous channel support with tokio integration

This commit is contained in:
Callum Leslie 2026-03-04 20:51:20 +00:00
parent 56d0889b37
commit 863ca61215
13 changed files with 385 additions and 33 deletions

View file

@ -0,0 +1,27 @@
use async_trait::async_trait;
pub use crate::error::Error as ChannelError;
#[async_trait]
pub trait AsyncChannelSender<T>: Send + Sync {
async fn send(&self, msg: T) -> Result<(), ChannelError>;
}
#[async_trait]
pub trait AsyncChannelReceiver<T>: Send + Sync {
async fn recv(&self) -> Result<T, ChannelError>;
}
pub trait AsyncChannelType {
type Sender<T: Send + 'static>: AsyncChannelSender<T>;
type Receiver<T: Send + 'static>: AsyncChannelReceiver<T>;
fn create_request_channel() -> (
Self::Sender<crate::types::Request>,
Self::Receiver<crate::types::Request>,
);
fn create_response_channel<T: Send + 'static>() -> (
Self::Sender<crate::types::Response<T>>,
Self::Receiver<crate::types::Response<T>>,
);
}