Skip to main content

ClientFacts

Trait ClientFacts 

Source
pub trait ClientFacts:
    AsyncRuntime
    + 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 { ... }
}
Expand description

A trait implemented by the user for the client-side, to define the customizable plugin.

§NOTE

If you choose implement this trait rather than use ClientDefault. We recommend your implementation to Deref<Target=orb::AsyncRuntime> then the blanket trait in orb::AsyncRuntime will automatically impl AsyncRuntime on your ClientFacts type. Refer to the code of ClientDefault for example.

Required Associated Types§

Source

type Codec: Codec

Define the codec to serialization and deserialization

Refers to Codec

Source

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§

Source

fn get_config(&self) -> &ClientConfig

You should keep ClientConfig inside, get_config() will return the reference.

Source

fn new_logger(&self) -> Arc<LogFilter>

Construct a captains_log::filter::Filter to oganize log of a client

Provided Methods§

Source

fn error_handle(&self, task: Self::Task)

TODO Fix the logger interface How to deal with error

The FailoverPool will overwrite this to implement retry logic

Source

fn get_client_id(&self) -> u64

You can overwrite this to assign a client_id

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§