obfuscate/impls/
openmls.rs

1use std::fmt::Formatter;
2
3use openmls::prelude::{KeyPackageSecretEncapsulation, Proposal, QueuedProposal, Sender};
4
5use crate::Obfuscate;
6
7impl Obfuscate for Proposal {
8    fn obfuscate(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
9        f.write_str(match self {
10            Proposal::Add(_) => "Add",
11            Proposal::Update(_) => "Update",
12            Proposal::Remove(_) => "Remove",
13            Proposal::PreSharedKey(_) => "PreSharedKey",
14            Proposal::ReInit(_) => "ReInit",
15            Proposal::ExternalInit(_) => "ExternalInit",
16            Proposal::AppAck(_) => "AppAck",
17            Proposal::GroupContextExtensions(_) => "GroupContextExtensions",
18        })
19    }
20}
21
22impl Obfuscate for KeyPackageSecretEncapsulation {
23    fn obfuscate(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
24        f.write_str("<secret>")
25    }
26}
27
28impl Obfuscate for QueuedProposal {
29    fn obfuscate(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
30        self.proposal.obfuscate(f)
31    }
32}
33
34impl Obfuscate for Sender {
35    fn obfuscate(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
36        match self {
37            Sender::Member(leaf_node_index) => write!(f, "Member{leaf_node_index}"),
38            Sender::External(external_sender_index) => write!(f, "External{external_sender_index:?}"),
39            Sender::NewMemberProposal => write!(f, "NewMemberProposal"),
40            Sender::NewMemberCommit => write!(f, "NewMemberCommit"),
41        }
42    }
43}