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:
- razor-rpc-tcp: For TCP and Unix socket
Required Associated Types§
type Listener: AsyncListener
Required Methods§
fn bind(addr: &str) -> impl Future<Output = Result<Self::Listener>> + Send
Sourcefn new_conn(
stream: <Self::Listener as AsyncListener>::Conn,
config: &ServerConfig,
conn_count: Arc<()>,
) -> Self
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
Sourcefn read_req<'a>(
&'a self,
logger: &LogFilter,
close_ch: &MAsyncRx<Null>,
) -> impl Future<Output = Result<RpcSvrReq<'a>, RpcIntErr>> + Send
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
Sourcefn write_resp<T: ServerTaskEncode>(
&self,
logger: &LogFilter,
codec: &impl Codec,
task: T,
) -> impl Future<Output = Result<()>> + Send
fn write_resp<T: ServerTaskEncode>( &self, logger: &LogFilter, codec: &impl Codec, task: T, ) -> impl Future<Output = Result<()>> + Send
Write our user task response
Sourcefn write_resp_internal(
&self,
logger: &LogFilter,
seq: u64,
err: Option<RpcIntErr>,
) -> impl Future<Output = Result<()>> + Send
fn write_resp_internal( &self, logger: &LogFilter, seq: u64, err: Option<RpcIntErr>, ) -> impl Future<Output = Result<()>> + Send
Write out ping resp or error
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.