Skip to main content

ServerTransport

Trait ServerTransport 

Source
pub trait ServerTransport:
    Send
    + Sync
    + Sized
    + 'static
    + Debug {
    type Listener: AsyncListener;

    // Required methods
    fn bind(addr: &str) -> impl Future<Output = Result<Self::Listener>> + Send;
    fn new_conn(
        stream: <Self::Listener as AsyncListener>::Conn,
        config: &ServerConfig,
        conn_count: Arc<()>,
    ) -> Self;
    fn read_req<'a>(
        &'a self,
        logger: &LogFilter,
        close_ch: &MAsyncRx<Null>,
    ) -> impl Future<Output = Result<RpcSvrReq<'a>, RpcIntErr>> + Send;
    fn write_resp<T: ServerTaskEncode>(
        &self,
        logger: &LogFilter,
        codec: &impl Codec,
        task: T,
    ) -> impl Future<Output = Result<()>> + Send;
    fn write_resp_internal(
        &self,
        logger: &LogFilter,
        seq: u64,
        err: Option<RpcIntErr>,
    ) -> impl Future<Output = Result<()>> + Send;
    fn flush_resp(
        &self,
        logger: &LogFilter,
    ) -> impl Future<Output = Result<()>> + Send;
    fn close_conn(&self, logger: &LogFilter) -> impl Future<Output = ()> + Send;
}
Expand description

This trait is for server-side transport layer protocol.

The implementation can be found on:

Required Associated Types§

Required Methods§

Source

fn bind(addr: &str) -> impl Future<Output = Result<Self::Listener>> + Send

Source

fn new_conn( stream: <Self::Listener as AsyncListener>::Conn, config: &ServerConfig, conn_count: Arc<()>, ) -> Self

The implementation is expected to store the conn_count until dropped

Source

fn read_req<'a>( &'a self, logger: &LogFilter, close_ch: &MAsyncRx<Null>, ) -> impl Future<Output = Result<RpcSvrReq<'a>, RpcIntErr>> + Send

Read a request from the socket

Source

fn write_resp<T: ServerTaskEncode>( &self, logger: &LogFilter, codec: &impl Codec, task: T, ) -> impl Future<Output = Result<()>> + Send

Write our user task response

Source

fn write_resp_internal( &self, logger: &LogFilter, seq: u64, err: Option<RpcIntErr>, ) -> impl Future<Output = Result<()>> + Send

Write out ping resp or error

Source

fn flush_resp( &self, logger: &LogFilter, ) -> impl Future<Output = Result<()>> + Send

Flush the response for the socket writer, if the transport has buffering logic

Source

fn close_conn(&self, logger: &LogFilter) -> impl Future<Output = ()> + Send

Shutdown the write direction of the connection

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§