openmls/group/mls_group/
app_ephemeral.rs

1use crate::{
2    component::ComponentId,
3    group::proposal_store::{ProposalQueue, QueuedAppEphemeralProposal},
4};
5
6use std::collections::BTreeSet;
7
8impl ProposalQueue {
9    /// Return an iterator over the [`QueuedAppEphemeralProposal`]s in the proposal queue,
10    /// in the order they appear in the commit.
11    pub fn app_ephemeral_proposals_for_component_id(
12        &self,
13        component_id: ComponentId,
14    ) -> impl Iterator<Item = QueuedAppEphemeralProposal<'_>> {
15        self.app_ephemeral_proposals()
16            .filter(move |p| p.app_ephemeral_proposal().component_id() == component_id)
17    }
18
19    /// Return the list of all [`ComponentId`]s available across all
20    /// [`QueuedAppEphemeralProposal`]s in the proposal queue, ordered by [`ComponentId`].
21    pub fn unique_component_ids_for_app_ephemeral(&self) -> Vec<ComponentId> {
22        // sort and deduplicate
23        let ids: BTreeSet<_> = self
24            .app_ephemeral_proposals()
25            .map(|p| p.app_ephemeral_proposal().component_id())
26            .collect();
27
28        ids.into_iter().collect()
29    }
30}