embassy_socket/tcp_server/
callback.rs

1use embassy_net::IpEndpoint;
2use crate::channel::WriteChannel;
3use crate::err::SocketErr;
4
5/// tcp server callback
6pub trait TcpServerCallBack {
7    /// data processed independently on a single connection, ensure data atomicity for a single connection
8    type T;
9
10    /// connection success call this
11    async fn conn<const CN: usize>(&self, endpoint: IpEndpoint, wch: &WriteChannel<'_, CN>, t: &mut Self::T);
12
13    /// connection lost call this
14    async fn dis_conn(&self, endpoint: IpEndpoint, t: &mut Self::T);
15
16    /// recv tcp client data call this
17    async fn recv<const CN: usize>(&self, endpoint: IpEndpoint, buf: &[u8], wch: &WriteChannel<'_, CN>, t: &mut Self::T);
18
19    /// socket err will call this<br />
20    /// only error notification will be made, no blocking and exit will be made<br />
21    /// please do not use endless loops in this method
22    async fn err(&self, err: SocketErr, t: &mut Self::T);
23}