use async_trait::async_trait; use crate::{ AppendEntriesArgs, AppendEntriesReply, InstallSnapshotArgs, InstallSnapshotReply, RequestVoteArgs, RequestVoteReply, }; #[async_trait] pub trait RemoteRaft: Send + Sync { async fn request_vote( &self, args: RequestVoteArgs, ) -> std::io::Result; async fn append_entries( &self, args: AppendEntriesArgs, ) -> std::io::Result; async fn install_snapshot( &self, args: InstallSnapshotArgs, ) -> std::io::Result; } #[async_trait] impl RemoteRaft for R where Command: Send + 'static, R: AsRef> + Send + Sync, { async fn request_vote( &self, args: RequestVoteArgs, ) -> std::io::Result { self.as_ref().request_vote(args).await } async fn append_entries( &self, args: AppendEntriesArgs, ) -> std::io::Result { self.as_ref().append_entries(args).await } async fn install_snapshot( &self, args: InstallSnapshotArgs, ) -> std::io::Result { self.as_ref().install_snapshot(args).await } }