pub trait StateMachineBackend: Send + Sync {
// Required methods
fn apply(&self, command: &Command, index: u64) -> CommandResult;
fn get(&self, key: &str) -> Option<Vec<u8>>;
fn last_applied(&self) -> u64;
fn version(&self) -> u64;
fn len(&self) -> usize;
fn snapshot(&self) -> Snapshot;
fn restore(&self, snapshot: Snapshot);
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Trait for pluggable state machine backends. Implementations can delegate to in-memory storage, disk-based storage, or any other backend.
Required Methods§
Sourcefn apply(&self, command: &Command, index: u64) -> CommandResult
fn apply(&self, command: &Command, index: u64) -> CommandResult
Apply a command to the state machine at the given log index.
Sourcefn last_applied(&self) -> u64
fn last_applied(&self) -> u64
Get the last applied log index.