pub trait MlsRules: Send + Sync {
type Error: IntoAnyError;
// Required methods
fn filter_proposals(
&self,
direction: CommitDirection,
source: CommitSource,
current_roster: &Roster<'_>,
current_context: &GroupContext,
proposals: ProposalBundle,
) -> Result<ProposalBundle, Self::Error>;
fn commit_options(
&self,
new_roster: &Roster<'_>,
new_context: &GroupContext,
proposals: &ProposalBundle,
) -> Result<CommitOptions, Self::Error>;
fn encryption_options(
&self,
current_roster: &Roster<'_>,
current_context: &GroupContext,
) -> Result<EncryptionOptions, Self::Error>;
}
Expand description
A set of user controlled rules that customize the behavior of MLS.
Required Associated Types§
type Error: IntoAnyError
Required Methods§
Sourcefn filter_proposals(
&self,
direction: CommitDirection,
source: CommitSource,
current_roster: &Roster<'_>,
current_context: &GroupContext,
proposals: ProposalBundle,
) -> Result<ProposalBundle, Self::Error>
fn filter_proposals( &self, direction: CommitDirection, source: CommitSource, current_roster: &Roster<'_>, current_context: &GroupContext, proposals: ProposalBundle, ) -> Result<ProposalBundle, Self::Error>
This is called when preparing or receiving a commit to pre-process the set of committed proposals.
Both proposals received during the current epoch and at the time of commit will be presented for validation and filtering. Filter and validate will present a raw list of proposals. Standard MLS rules are applied internally on the result of these rules.
Each member of a group MUST apply the same proposal rules in order to maintain a working group.
Typically, any invalid proposal should result in an error. The exception are invalid by-reference proposals processed when preparing a commit, which should be filtered out instead. This is to avoid the deadlock situation when no commit can be generated after receiving an invalid set of proposal messages.
ProposalBundle
can be arbitrarily modified. For example, a Remove proposal that
removes a moderator can result in adding a GroupContextExtensions proposal that updates
the moderator list in the group context. The resulting ProposalBundle
is validated
by the library.
Sourcefn commit_options(
&self,
new_roster: &Roster<'_>,
new_context: &GroupContext,
proposals: &ProposalBundle,
) -> Result<CommitOptions, Self::Error>
fn commit_options( &self, new_roster: &Roster<'_>, new_context: &GroupContext, proposals: &ProposalBundle, ) -> Result<CommitOptions, Self::Error>
This is called when preparing a commit to determine various options: whether to enforce an update path in case it is not mandated by MLS, whether to include the ratchet tree in the welcome message (if the commit adds members) and whether to generate a single welcome message, or one welcome message for each added member.
The new_roster
and new_extension_list
describe the group state after the commit.
Sourcefn encryption_options(
&self,
current_roster: &Roster<'_>,
current_context: &GroupContext,
) -> Result<EncryptionOptions, Self::Error>
fn encryption_options( &self, current_roster: &Roster<'_>, current_context: &GroupContext, ) -> Result<EncryptionOptions, Self::Error>
This is called when sending any packet. For proposals and commits, this determines whether to encrypt them. For any encrypted packet, this determines the padding mode used.
Note that for commits, the current_roster
and current_extension_list
describe the group state
before the commit, unlike in commit_options.