Trait TcpServerCallBack

Source
pub trait TcpServerCallBack: Copy {
    // Required methods
    async fn conn<const CN: usize>(
        &self,
        endpoint: IpEndpoint,
        wch: &WriteChannel<'_, CN>,
    );
    async fn dis_conn(&self, endpoint: IpEndpoint);
    async fn recv<const CN: usize>(
        &self,
        endpoint: IpEndpoint,
        buf: &[u8],
        wch: &WriteChannel<'_, CN>,
    );
    async fn err(&self, err: SocketErr);
}
Expand description

tcp server回调

Required Methods§

Source

async fn conn<const CN: usize>( &self, endpoint: IpEndpoint, wch: &WriteChannel<'_, CN>, )

有连接进来时回调此

Source

async fn dis_conn(&self, endpoint: IpEndpoint)

连接断开后的回调

Source

async fn recv<const CN: usize>( &self, endpoint: IpEndpoint, buf: &[u8], wch: &WriteChannel<'_, CN>, )

数据读取

Source

async fn err(&self, err: SocketErr)

socket err will call this
only error notification will be made, no blocking and exit will be made
please do not use endless loops in this method

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§