pub struct StateMachine { /* private fields */ }Expand description
A redb-backed replicated state machine.
Implementations§
Source§impl StateMachine
impl StateMachine
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, StateMachineError>
pub fn open(path: impl AsRef<Path>) -> Result<Self, StateMachineError>
Open (or create) a redb-backed state machine, creating the required tables up front.
Sourcepub fn apply(&self, cmd: &Cmd) -> Result<CmdResult, StateMachineError>
pub fn apply(&self, cmd: &Cmd) -> Result<CmdResult, StateMachineError>
Apply a single command deterministically (called by every node once Raft has committed it).
Sourcepub fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, StateMachineError>
pub fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, StateMachineError>
Read a KV pair (a local read; linearizability is guaranteed by the Raft read-index above).
Trait Implementations§
Source§impl Clone for StateMachine
impl Clone for StateMachine
Source§fn clone(&self) -> StateMachine
fn clone(&self) -> StateMachine
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for StateMachine
impl !UnwindSafe for StateMachine
impl Freeze for StateMachine
impl Send for StateMachine
impl Sync for StateMachine
impl Unpin for StateMachine
impl UnsafeUnpin for StateMachine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more