Trait openraft::RaftTypeConfig

source ·
pub trait RaftTypeConfig: Sized + OptionalSend + OptionalSync + Debug + Clone + Copy + Default + Eq + PartialEq + Ord + PartialOrd + 'static {
    type D: AppData;
    type R: AppDataResponse;
    type NodeId: NodeId;
    type Node: Node;
    type Entry: RaftEntry<Self::NodeId, Self::Node> + FromAppData<Self::D>;
    type SnapshotData: OptionalSend + 'static;
    type AsyncRuntime: AsyncRuntime;
    type Responder: Responder<Self>;
}
Expand description

Configuration of types used by the Raft core engine.

The (empty) implementation structure defines request/response types, node ID type and the like. Refer to the documentation of associated types for more information.

§Note

Since Rust cannot automatically infer traits for various inner types using this config type as a parameter, this trait simply uses all the traits required for various types as its supertraits as a workaround. To ease the declaration, the macro declare_raft_types is provided, which can be used to declare the type easily.

Example:

openraft::declare_raft_types!(
   pub TypeConfig:
       D            = ClientRequest,
       R            = ClientResponse,
       NodeId       = u64,
       Node         = openraft::BasicNode,
       Entry        = openraft::Entry<TypeConfig>,
       SnapshotData = Cursor<Vec<u8>>,
       AsyncRuntime = openraft::TokioRuntime,
);

Required Associated Types§

source

type D: AppData

Application-specific request data passed to the state machine.

source

type R: AppDataResponse

Application-specific response data returned by the state machine.

source

type NodeId: NodeId

A Raft node’s ID.

source

type Node: Node

Raft application level node data

source

type Entry: RaftEntry<Self::NodeId, Self::Node> + FromAppData<Self::D>

Raft log entry, which can be built from an AppData.

source

type SnapshotData: OptionalSend + 'static

source

type AsyncRuntime: AsyncRuntime

Asynchronous runtime type.

source

type Responder: Responder<Self>

Send the response or error of a client write request(WriteResult).

For example, return WriteResult the to the caller of Raft::client_write, or send to some application defined channel.

Object Safety§

This trait is not object safe.

Implementors§