pub trait ClientFacts:
Send
+ Sync
+ Sized
+ 'static {
type Codec: Codec;
type Task: ClientTask;
// Required methods
fn get_config(&self) -> &ClientConfig;
fn new_logger(&self) -> Arc<LogFilter>;
// Provided methods
fn error_handle(&self, task: Self::Task) { ... }
fn get_client_id(&self) -> u64 { ... }
fn get_timestamp(&self) -> u64 { ... }
}Expand description
A trait implemented by the user for the client-side, to define the customizable plugin.
Required Associated Types§
Sourcetype Task: ClientTask
type Task: ClientTask
Define the RPC task from client-side
Either one ClientTask or an enum of multiple ClientTask.
If you have multiple task type, recommend to use the enum_dispatch crate.
You can use macro client_task_enum and client_task on task type
Required Methods§
Sourcefn get_config(&self) -> &ClientConfig
fn get_config(&self) -> &ClientConfig
You should keep ClientConfig inside, get_config() will return the reference.
Sourcefn new_logger(&self) -> Arc<LogFilter>
fn new_logger(&self) -> Arc<LogFilter>
Construct a captains_log::filter::Filter to oganize log of a client
TODO: Fix the logger interface
Provided Methods§
Sourcefn error_handle(&self, task: Self::Task)
fn error_handle(&self, task: Self::Task)
How to deal with error
The FailoverPool will overwrite this to implement retry logic
Sourcefn get_client_id(&self) -> u64
fn get_client_id(&self) -> u64
You can overwrite this to assign a client_id
Sourcefn get_timestamp(&self) -> u64
fn get_timestamp(&self) -> u64
NOTE: you may overwrite this to use coarstime or quanta
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.