Struct CommitBuilder

Source
pub struct CommitBuilder<'a, T> { /* private fields */ }
Expand description

The CommitBuilder is used to easily and dynamically build commit messages. It operates in a series of stages:

The Initial stage is used to populate the builder with proposals and other data using method calls on the builder that let the builder stay in the same stage.

The next stage is LoadedPsks, and it signifies the stage after the builder loaded the the pre-shared keys for the PreSharedKey proposals in this commit.

Then comes the Complete stage, which denotes that all data has been validated. From this stage, the commit can be staged in the group, and the outgoing messages returned.

For example, to create a commit to a new Add proposal with a KeyPackage key_package_to_add that does not commit to the proposals in the proposal store, one could build the commit as follows:

let message_bundle: CommitMessageBundle = mls_group
  .commit_builder()
  .consume_proposal_store(false)
  .add_proposal(key_package_to_add)
  .load_psks(provider.storage())?
  .build(provider.rand(), provider.crypto(), signer, app_policy_proposals)?
  .stage_commit(provider)?;

let commit = message_bundle.commit();
let welcome = message_bundle.welcome().expect("expected a welcome since there was an add");
let group_info = message_bundle.welcome().expect("expected a group info since there was an add");

In this example signer is a reference to a [Signer] and app_policy_proposals is the application-defined policy for which proposals to accept, implemented by an FnMut(&QueuedProposal) -> bool.

See the book for another example.

Implementations§

Source§

impl<'a> CommitBuilder<'a, Initial>

Source

pub fn new(group: &'a mut MlsGroup) -> Self

returns a new CommitBuilder for the given MlsGroup.

Source

pub fn consume_proposal_store(self, consume_proposal_store: bool) -> Self

Sets whether or not the proposals in the proposal store of the group should be included in the commit. Defaults to true.

Source

pub fn create_group_info(self, create_group_info: bool) -> Self

Sets whether or not a GroupInfo should be created when the commit is staged. Defaults to the value of the MlsGroups MlsGroupJoinConfig.

Source

pub fn force_self_update(self, force_self_update: bool) -> Self

Sets whether or not the commit should force a self-update. Defaults to false.

Source

pub fn add_proposal(self, proposal: Proposal) -> Self

Adds a proposal to the proposals to be committed.

Source

pub fn add_proposals( self, proposals: impl IntoIterator<Item = Proposal>, ) -> Self

Adds the proposals in the iterator to the proposals to be committed.

Source

pub fn leaf_node_parameters( self, leaf_node_parameters: LeafNodeParameters, ) -> Self

Sets the leaf node parameters for the new leaf node in a self-update. Implies that a self-update takes place.

Source

pub fn propose_adds( self, key_packages: impl IntoIterator<Item = KeyPackage>, ) -> Self

Adds an Add proposal to the provided KeyPackage to the list of proposals to be committed.

Source

pub fn propose_removals( self, removed: impl IntoIterator<Item = LeafNodeIndex>, ) -> Self

Adds a Remove proposal for the provided LeafNodeIndexes to the list of proposals to be committed.

Source

pub fn propose_group_context_extensions(self, extensions: Extensions) -> Self

Adds a GroupContextExtensions proposal for the provided Extensions to the list of proposals to be committed.

Source

pub fn load_psks<Storage: StorageProvider>( self, storage: &'a Storage, ) -> Result<CommitBuilder<'a, LoadedPsks>, CreateCommitError>

Loads the PSKs for the PskProposals marked for inclusion and moves on to the next phase.

Source§

impl<'a> CommitBuilder<'a, LoadedPsks>

Source

pub fn build<S: Signer>( self, rand: &impl OpenMlsRand, crypto: &impl OpenMlsCrypto, signer: &S, f: impl FnMut(&QueuedProposal) -> bool, ) -> Result<CommitBuilder<'a, Complete>, CreateCommitError>

Validates the inputs and builds the commit. The last argument f is a function that lets the caller filter the proposals that are considered for inclusion. This provides a way for the application to enforce custom policies in the creation of commits.

Source

pub fn build_with_new_signer<S: Signer>( self, rand: &impl OpenMlsRand, crypto: &impl OpenMlsCrypto, old_signer: &impl Signer, new_signer: NewSignerBundle<'_, S>, f: impl FnMut(&QueuedProposal) -> bool, ) -> Result<CommitBuilder<'a, Complete>, CreateCommitError>

Just like build, this function validates the inputs and builds the commit. The last argument f is a function that lets the caller filter the proposals that are considered for inclusion. This provides a way for the application to enforce custom policies in the creation of commits.

In contrast to build, this function can be used to create commits that rotate the own leaf node’s signature key.

Source§

impl CommitBuilder<'_, Complete>

Source

pub fn stage_commit<Provider: OpenMlsProvider>( self, provider: &Provider, ) -> Result<CommitMessageBundle, CommitBuilderStageError<Provider::StorageError>>

Stages the commit and returns the protocol messages.

Trait Implementations§

Source§

impl<'a, T: Debug> Debug for CommitBuilder<'a, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for CommitBuilder<'a, T>
where T: Freeze,

§

impl<'a, T> RefUnwindSafe for CommitBuilder<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for CommitBuilder<'a, T>
where T: Send,

§

impl<'a, T> Sync for CommitBuilder<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for CommitBuilder<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for CommitBuilder<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.