embassy_socket/tcp_server/callback.rs
1use embassy_net::IpEndpoint;
2use crate::channel::WriteChannel;
3use crate::err::SocketErr;
4
5/// tcp server回调
6pub trait TcpServerCallBack: Copy {
7 /// 有连接进来时回调此
8 async fn conn<const CN: usize>(&self, endpoint: IpEndpoint, wch: &WriteChannel<'_, CN>);
9
10 /// 连接断开后的回调
11 async fn dis_conn(&self, endpoint: IpEndpoint);
12
13 /// 数据读取
14 async fn recv<const CN: usize>(&self, endpoint: IpEndpoint, buf: &[u8], wch: &WriteChannel<'_, CN>);
15
16 /// socket err will call this<br />
17 /// only error notification will be made, no blocking and exit will be made<br />
18 /// please do not use endless loops in this method
19 async fn err(&self, err: SocketErr);
20}