use core::future::Future;
pub trait ClientTransport<Req, Resp> {
type Error;
fn call(&self, req: Req) -> impl Future<Output = Result<Resp, Self::Error>>;
}
impl<T, Req, Resp> ClientTransport<Req, Resp> for &T
where
T: ClientTransport<Req, Resp>,
{
type Error = T::Error;
fn call(&self, req: Req) -> impl Future<Output = Result<Resp, Self::Error>> {
(**self).call(req)
}
}
pub trait ServerTransport<Req, Resp> {
type Error;
type ReplyToken;
fn recv(&mut self) -> impl Future<Output = Result<(Req, Self::ReplyToken), Self::Error>>;
fn reply(
&self,
token: Self::ReplyToken,
resp: Resp,
) -> impl Future<Output = Result<(), Self::Error>>;
}