raftify/state_machine/
mod.rs

1use tonic::async_trait;
2
3use crate::Result;
4
5#[async_trait]
6pub trait AbstractStateMachine: Clone + Send + Sync {
7    async fn apply(&mut self, log_entry: Vec<u8>) -> Result<Vec<u8>>;
8    async fn snapshot(&self) -> Result<Vec<u8>>;
9    async fn restore(&mut self, snapshot: Vec<u8>) -> Result<()>;
10
11    fn encode(&self) -> Result<Vec<u8>>;
12    fn decode(bytes: &[u8]) -> Result<Self>
13    where
14        Self: Sized;
15}