use std::io;
use futures_util::Stream;
use openraft_macros::add_async_trait;
use openraft_macros::since;
use crate::OptionalSend;
use crate::OptionalSync;
use crate::RaftSnapshotBuilder;
use crate::RaftTypeConfig;
use crate::storage::EntryResponder;
use crate::type_config::alias::LogIdOf;
use crate::type_config::alias::SnapshotMetaOf;
use crate::type_config::alias::SnapshotOf;
use crate::type_config::alias::StoredMembershipOf;
#[add_async_trait]
pub trait RaftStateMachine<C>: OptionalSend + OptionalSync + 'static
where C: RaftTypeConfig
{
type SnapshotBuilder: RaftSnapshotBuilder<C>;
async fn applied_state(&mut self) -> Result<(Option<LogIdOf<C>>, StoredMembershipOf<C>), io::Error>;
#[since(version = "0.10.0", change = "Entry-Responder-Result stream")]
async fn apply<Strm>(&mut self, entries: Strm) -> Result<(), io::Error>
where Strm: Stream<Item = Result<EntryResponder<C>, io::Error>> + Unpin + OptionalSend;
#[since(version = "0.10.0")]
async fn try_create_snapshot_builder(&mut self, force: bool) -> Option<Self::SnapshotBuilder> {
let _ = force;
Some(self.get_snapshot_builder().await)
}
#[since(version = "0.10.0", change = "deprecated, use `try_create_snapshot_builder` instead")]
async fn get_snapshot_builder(&mut self) -> Self::SnapshotBuilder;
#[since(version = "0.10.0", change = "SnapshotData without Box")]
async fn begin_receiving_snapshot(&mut self) -> Result<C::SnapshotData, io::Error>;
#[since(version = "0.10.0", change = "SnapshotData without Box")]
async fn install_snapshot(&mut self, meta: &SnapshotMetaOf<C>, snapshot: C::SnapshotData) -> Result<(), io::Error>;
async fn get_current_snapshot(&mut self) -> Result<Option<SnapshotOf<C>>, io::Error>;
}