openmls/group/mls_group/
app_ephemeral.rs

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