dope_session/protocol/
client.rs1use crate::CodecLayer;
2use crate::SlotId;
3use crate::session::Egress;
4use dambi::Bytes;
5
6pub trait ClientFramer: 'static {
7 type Head;
8
9 fn parse(&mut self, buf: &Bytes) -> Option<(Self::Head, usize)>;
10}
11
12pub trait ClientProtocol: 'static {
13 type Framer: ClientFramer + Default + 'static;
14 type ConnState: Default + 'static;
15 type CodecLayer: CodecLayer;
16
17 fn on_connect(
18 &mut self,
19 conn_id: SlotId,
20 conn_state: &mut Self::ConnState,
21 out: Egress<'_, Self::CodecLayer>,
22 ) {
23 let _ = (conn_id, conn_state, out);
24 }
25
26 fn on_response(
27 &mut self,
28 conn_id: SlotId,
29 conn_state: &mut Self::ConnState,
30 head: <Self::Framer as ClientFramer>::Head,
31 out: Egress<'_, Self::CodecLayer>,
32 );
33
34 fn wants_close(&self, conn_state: &Self::ConnState) -> bool {
35 let _ = conn_state;
36 false
37 }
38
39 fn on_disconnect(
40 &mut self,
41 conn_id: SlotId,
42 conn_state: &mut Self::ConnState,
43 out: Egress<'_, Self::CodecLayer>,
44 ) {
45 let _ = (conn_id, conn_state, out);
46 }
47}