use protosocket::{Codec, Decoder, Encoder, SocketListener};
use crate::{server::rpc_responder::RpcResponder, Message};
pub trait SocketService: 'static {
type Codec: Codec + Decoder<Message: Message> + Encoder<Message: Message>;
type ConnectionService: ConnectionService<
Request = <Self::Codec as Decoder>::Message,
Response = <Self::Codec as Encoder>::Message,
>;
type SocketListener: SocketListener;
fn codec(&self) -> Self::Codec;
fn new_stream_service(
&self,
_stream: &<Self::SocketListener as SocketListener>::Stream,
) -> Self::ConnectionService;
}
pub trait ConnectionService: Unpin + 'static {
type Request: Message;
type Response: Message;
fn new_rpc(
&mut self,
initiating_message: Self::Request,
responder: RpcResponder<'_, Self::Response>,
);
fn poll(
self: std::pin::Pin<&mut Self>,
_context: &mut std::task::Context<'_>,
) -> std::ops::ControlFlow<()> {
std::ops::ControlFlow::Continue(())
}
}