1use futures::{Sink, Stream};
2use std::future::Future;
3
4use crate::RPCResult;
5
6pub type TransportInput<E> = Result<RPCData, E>;
8
9pub type RPCData = bytes::Bytes;
11
12pub trait TransportChannel: 'static {
14 type SinkError: std::error::Error + 'static + Sync + Send;
16
17 type StreamError: std::error::Error + 'static + Sync + Send;
18
19 type Input: Stream<Item = TransportInput<Self::StreamError>> + Unpin + Send + 'static;
21
22 type Output: Sink<RPCData, Error = Self::SinkError> + Unpin + Send + 'static;
23
24 fn spawn<Fut>(future: Fut)
25 where
26 Fut: Future<Output = RPCResult<()>> + Send + 'static;
27
28 fn framed(self) -> (Self::Input, Self::Output);
29}