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§
sourcetype R: AppDataResponse
type R: AppDataResponse
Application-specific response data returned by the state machine.
sourcetype Entry: RaftEntry<Self::NodeId, Self::Node> + FromAppData<Self::D>
type Entry: RaftEntry<Self::NodeId, Self::Node> + FromAppData<Self::D>
Raft log entry, which can be built from an AppData.
type SnapshotData: OptionalSend + 'static
sourcetype AsyncRuntime: AsyncRuntime
type AsyncRuntime: AsyncRuntime
Asynchronous runtime type.
sourcetype Responder: Responder<Self>
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.