Trait TcpServerCallBack

Source
pub trait TcpServerCallBack {
    type T;

    // Required methods
    async fn conn<const CN: usize>(
        &self,
        endpoint: IpEndpoint,
        wch: &WriteChannel<'_, CN>,
        t: &mut Self::T,
    );
    async fn dis_conn(&self, endpoint: IpEndpoint, t: &mut Self::T);
    async fn recv<const CN: usize>(
        &self,
        endpoint: IpEndpoint,
        buf: &[u8],
        wch: &WriteChannel<'_, CN>,
        t: &mut Self::T,
    );
    async fn err(&self, err: SocketErr, t: &mut Self::T);
}
Expand description

tcp server callback

Required Associated Types§

Source

type T

data processed independently on a single connection, ensure data atomicity for a single connection

Required Methods§

Source

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

connection success call this

Source

async fn dis_conn(&self, endpoint: IpEndpoint, t: &mut Self::T)

connection lost call this

Source

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

recv tcp client data call this

Source

async fn err(&self, err: SocketErr, t: &mut Self::T)

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§