pub trait ClientTransport:
Debug
+ Send
+ Sized
+ 'static {
// Required methods
fn connect(
addr: &str,
conn_id: &str,
config: &ClientConfig,
) -> impl Future<Output = Result<Self, RpcIntErr>> + Send;
fn close_conn<F: ClientFacts>(
&self,
logger: &LogFilter,
) -> impl Future<Output = ()> + Send;
fn flush_req<F: ClientFacts>(
&self,
logger: &LogFilter,
) -> impl Future<Output = Result<()>> + Send;
fn write_req<'a, F: ClientFacts>(
&'a self,
logger: &LogFilter,
buf: &'a [u8],
blob: Option<&'a [u8]>,
need_flush: bool,
) -> impl Future<Output = Result<()>> + Send;
fn read_resp<F: ClientFacts>(
&self,
facts: &F,
logger: &LogFilter,
codec: &F::Codec,
close_ch: Option<&mut AsyncRx<Null>>,
task_reg: &mut ClientTaskTimer<F>,
) -> impl Future<Output = Result<bool, RpcIntErr>> + Send;
}Expand description
This trait is for client-side transport layer protocol.
The implementation can be found on:
- razor-rpc-tcp: For TCP and Unix socket
§NOTE:
Instead of binding this to ClientFacts,
we use the associate type RT in generic param instead of ClientFacts to break cycle dep.
because FailoverPool will rewrap the facts into its own.
Required Methods§
Sourcefn connect(
addr: &str,
conn_id: &str,
config: &ClientConfig,
) -> impl Future<Output = Result<Self, RpcIntErr>> + Send
fn connect( addr: &str, conn_id: &str, config: &ClientConfig, ) -> impl Future<Output = Result<Self, RpcIntErr>> + Send
How to establish an async connection.
conn_id: used for log fmt, can by the same of addr.
Sourcefn close_conn<F: ClientFacts>(
&self,
logger: &LogFilter,
) -> impl Future<Output = ()> + Send
fn close_conn<F: ClientFacts>( &self, logger: &LogFilter, ) -> impl Future<Output = ()> + Send
Shutdown the write direction of the connection
Sourcefn flush_req<F: ClientFacts>(
&self,
logger: &LogFilter,
) -> impl Future<Output = Result<()>> + Send
fn flush_req<F: ClientFacts>( &self, logger: &LogFilter, ) -> impl Future<Output = Result<()>> + Send
Flush the request for the socket writer, if the transport has buffering logic
Sourcefn write_req<'a, F: ClientFacts>(
&'a self,
logger: &LogFilter,
buf: &'a [u8],
blob: Option<&'a [u8]>,
need_flush: bool,
) -> impl Future<Output = Result<()>> + Send
fn write_req<'a, F: ClientFacts>( &'a self, logger: &LogFilter, buf: &'a [u8], blob: Option<&'a [u8]>, need_flush: bool, ) -> impl Future<Output = Result<()>> + Send
Write out the encoded request task
Sourcefn read_resp<F: ClientFacts>(
&self,
facts: &F,
logger: &LogFilter,
codec: &F::Codec,
close_ch: Option<&mut AsyncRx<Null>>,
task_reg: &mut ClientTaskTimer<F>,
) -> impl Future<Output = Result<bool, RpcIntErr>> + Send
fn read_resp<F: ClientFacts>( &self, facts: &F, logger: &LogFilter, codec: &F::Codec, close_ch: Option<&mut AsyncRx<Null>>, task_reg: &mut ClientTaskTimer<F>, ) -> impl Future<Output = Result<bool, RpcIntErr>> + Send
Read the response and decode it from the socket, find and notify the registered ClientTask
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.