//! Helper functions for the protocol. use super::{Participant, ProtocolError, internal::SharedChannel}; use crate::participants::{ParticipantCounter, ParticipantList}; /// Gather exactly one message from each participant in a group before proceeding. pub async fn recv_from_others( chan: &SharedChannel, waitpoint: u64, participants: &ParticipantList, me: Participant, ) -> Result, ProtocolError> where T: serde::de::DeserializeOwned, { let mut seen = ParticipantCounter::new(participants); seen.put(me); let mut messages = Vec::with_capacity(participants.others(me).count()); while !seen.full() { let (from, msg) = chan.recv(waitpoint).await?; if seen.put(from) { messages.push((from, msg)); } } Ok(messages) }