use crate::CodecLayer;
use crate::SlotId;
use crate::session::Egress;
use dambi::Bytes;
pub trait ClientProtocol: 'static {
type Head;
type ConnState: Default + 'static;
type CodecLayer: CodecLayer;
fn parse(&self, state: &mut Self::ConnState, buf: &Bytes) -> Option<(Self::Head, usize)>;
fn on_connect(
&mut self,
conn_id: SlotId,
conn_state: &mut Self::ConnState,
out: Egress<'_, Self::CodecLayer>,
) {
let _ = (conn_id, conn_state, out);
}
fn on_response(
&mut self,
conn_id: SlotId,
conn_state: &mut Self::ConnState,
head: Self::Head,
out: Egress<'_, Self::CodecLayer>,
);
fn wants_close(&self, conn_state: &Self::ConnState) -> bool {
let _ = conn_state;
false
}
fn on_disconnect(
&mut self,
conn_id: SlotId,
conn_state: &mut Self::ConnState,
out: Egress<'_, Self::CodecLayer>,
) {
let _ = (conn_id, conn_state, out);
}
}