pub struct VcKeyPackageBatchBuilder { /* private fields */ }virtual-clients-draft and (32-bit or 64-bit) only.Expand description
A builder for a batch of virtual-client KeyPackages a sibling can reproduce.
Allows to build heterogeneous batch of key packages, e.g. non-last-resort and last-restort, or
packages with different ciphersuits. Return the batch on Self::finalize. Dropping the
builder without calling finalize burns no generation.
Implementations§
Source§impl VcKeyPackageBatchBuilder
impl VcKeyPackageBatchBuilder
Sourcepub fn new(
provider: &impl OpenMlsProvider,
epoch_id: EpochId,
) -> Result<Self, KeyPackageNewError>
pub fn new( provider: &impl OpenMlsProvider, epoch_id: EpochId, ) -> Result<Self, KeyPackageNewError>
Load emulation epoch and allocate the next generation of the key package operation ratchet.
Nothing is persisted yet. Dropping the builder without calling finalize burns no
generation.
Sourcepub fn with_capacity(
provider: &impl OpenMlsProvider,
epoch_id: EpochId,
capacity: usize,
) -> Result<Self, KeyPackageNewError>
pub fn with_capacity( provider: &impl OpenMlsProvider, epoch_id: EpochId, capacity: usize, ) -> Result<Self, KeyPackageNewError>
Same as Self::new, but with a capacity hint for the number of key packages.
Sourcepub fn add_key_package(
&mut self,
builder: KeyPackageBuilder,
ciphersuite: Ciphersuite,
crypto: &impl OpenMlsCrypto,
signer: &impl Signer,
credential_with_key: CredentialWithKey,
) -> Result<&KeyPackageInfo, KeyPackageNewError>
pub fn add_key_package( &mut self, builder: KeyPackageBuilder, ciphersuite: Ciphersuite, crypto: &impl OpenMlsCrypto, signer: &impl Signer, credential_with_key: CredentialWithKey, ) -> Result<&KeyPackageInfo, KeyPackageNewError>
Build one key package at the next index.
The key package builder carries the per-step config: key package extensions (incl. last resort), leaf node extensions, capabilities, lifetime.
If building fails, the builder is left in a valid state:
- No storage is touched
- No generation is burned
- The failed index isn’t consumed
Sourcepub fn finalize(
self,
provider: &impl OpenMlsProvider,
) -> Result<VcKeyPackageBatch, KeyPackageNewError>
pub fn finalize( self, provider: &impl OpenMlsProvider, ) -> Result<VcKeyPackageBatch, KeyPackageNewError>
Finalize the batch.
Persists the operation tree and the key packages. The operation is not atomic. On failure, the generation should be considered as burned. Few orphaned key packages may be left in storage.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for VcKeyPackageBatchBuilder
impl RefUnwindSafe for VcKeyPackageBatchBuilder
impl Send for VcKeyPackageBatchBuilder
impl Sync for VcKeyPackageBatchBuilder
impl Unpin for VcKeyPackageBatchBuilder
impl UnsafeUnpin for VcKeyPackageBatchBuilder
impl UnwindSafe for VcKeyPackageBatchBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Classify for T
impl<T> Classify for T
type Classified = T
fn classify(self) -> T
§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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