mls_rs::external_client::builder

Struct ExternalClientBuilder

source
pub struct ExternalClientBuilder<C>(/* private fields */);
Available on crate feature external_client only.
Expand description

Builder for ExternalClient

This is returned by ExternalClient::builder and allows to tweak settings the ExternalClient will use. At a minimum, the builder must be told the CryptoProvider and IdentityProvider to use. Other settings have default values. This means that the following methods must be called before ExternalClientBuilder::build:

§Example

use mls_rs::{
    external_client::ExternalClient,
    identity::basic::BasicIdentityProvider,
};

use mls_rs_crypto_openssl::OpensslCryptoProvider;

let _client = ExternalClient::builder()
    .crypto_provider(OpensslCryptoProvider::default())
    .identity_provider(BasicIdentityProvider::new())
    .build();

§Spelling out an ExternalClient type

There are two main ways to spell out an ExternalClient type if needed (e.g. function return type).

The first option uses impl MlsConfig:

use mls_rs::{
    external_client::{ExternalClient, builder::MlsConfig},
    identity::basic::BasicIdentityProvider,
};

use mls_rs_crypto_openssl::OpensslCryptoProvider;

fn make_client() -> ExternalClient<impl MlsConfig> {
    ExternalClient::builder()
        .crypto_provider(OpensslCryptoProvider::default())
        .identity_provider(BasicIdentityProvider::new())
        .build()
}

The second option is more verbose and consists in writing the full ExternalClient type:

use mls_rs::{
    external_client::{ExternalClient, builder::{ExternalBaseConfig, WithIdentityProvider, WithCryptoProvider}},
    identity::basic::BasicIdentityProvider,
};

use mls_rs_crypto_openssl::OpensslCryptoProvider;

type MlsClient = ExternalClient<WithIdentityProvider<
    BasicIdentityProvider,
    WithCryptoProvider<OpensslCryptoProvider, ExternalBaseConfig>,
>>;

fn make_client_2() -> MlsClient {
    ExternalClient::builder()
        .crypto_provider(OpensslCryptoProvider::new())
        .identity_provider(BasicIdentityProvider::new())
        .build()
}

Implementations§

source§

impl ExternalClientBuilder<ExternalBaseConfig>

source

pub fn new() -> Self

source§

impl<C: IntoConfig> ExternalClientBuilder<C>

source

pub fn extension_type( self, type_: ExtensionType, ) -> ExternalClientBuilder<IntoConfigOutput<C>>

Add an extension type to the list of extension types supported by the client.

source

pub fn extension_types<I>( self, types: I, ) -> ExternalClientBuilder<IntoConfigOutput<C>>
where I: IntoIterator<Item = ExtensionType>,

Add multiple extension types to the list of extension types supported by the client.

source

pub fn custom_proposal_type( self, type_: ProposalType, ) -> ExternalClientBuilder<IntoConfigOutput<C>>

Add a custom proposal type to the list of proposals types supported by the client.

source

pub fn custom_proposal_types<I>( self, types: I, ) -> ExternalClientBuilder<IntoConfigOutput<C>>
where I: IntoIterator<Item = ProposalType>,

Add multiple custom proposal types to the list of proposal types supported by the client.

source

pub fn protocol_version( self, version: ProtocolVersion, ) -> ExternalClientBuilder<IntoConfigOutput<C>>

Add a protocol version to the list of protocol versions supported by the client.

If no protocol version is explicitly added, the client will support all protocol versions supported by this crate.

source

pub fn protocol_versions<I>( self, versions: I, ) -> ExternalClientBuilder<IntoConfigOutput<C>>
where I: IntoIterator<Item = ProtocolVersion>,

Add multiple protocol versions to the list of protocol versions supported by the client.

If no protocol version is explicitly added, the client will support all protocol versions supported by this crate.

source

pub fn external_signing_key( self, id: Vec<u8>, key: SignaturePublicKey, ) -> ExternalClientBuilder<IntoConfigOutput<C>>

Add an external signing key to be used by the client.

source

pub fn max_epoch_jitter( self, max_jitter: u64, ) -> ExternalClientBuilder<IntoConfigOutput<C>>

Specify the number of epochs before the current one to keep.

By default, all epochs are kept.

source

pub fn cache_proposals( self, cache_proposals: bool, ) -> ExternalClientBuilder<IntoConfigOutput<C>>

Specify whether processed proposals should be cached by the external group. In case they are not cached by the group, they should be cached externally and inserted using ExternalGroup::insert_proposal before processing the next commit.

source

pub fn identity_provider<I>( self, identity_provider: I, ) -> ExternalClientBuilder<WithIdentityProvider<I, C>>

Set the identity validator to be used by the client.

source

pub fn crypto_provider<Cp>( self, crypto_provider: Cp, ) -> ExternalClientBuilder<WithCryptoProvider<Cp, C>>
where Cp: CryptoProvider,

Set the crypto provider to be used by the client.

source

pub fn mls_rules<Pr>( self, mls_rules: Pr, ) -> ExternalClientBuilder<WithMlsRules<Pr, C>>
where Pr: MlsRules,

Set the user-defined proposal rules to be used by the client.

User-defined rules are used when sending and receiving commits before enforcing general MLS protocol rules. If the rule set returns an error when receiving a commit, the entire commit is considered invalid. If the rule set would return an error when sending a commit, individual proposals may be filtered out to compensate.

source

pub fn signer( self, signer: SignatureSecretKey, signing_identity: SigningIdentity, ) -> ExternalClientBuilder<IntoConfigOutput<C>>

Set the signature secret key used by the client to send external proposals.

source§

impl<C: IntoConfig> ExternalClientBuilder<C>
where C::IdentityProvider: IdentityProvider + Clone, C::MlsRules: MlsRules + Clone, C::CryptoProvider: CryptoProvider + Clone,

source

pub fn build(self) -> ExternalClient<IntoConfigOutput<C>>

Build an external client.

See ExternalClientBuilder documentation if the return type of this function needs to be spelled out.

Trait Implementations§

source§

impl<C: Debug> Debug for ExternalClientBuilder<C>

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for ExternalClientBuilder<ExternalBaseConfig>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<C> Freeze for ExternalClientBuilder<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for ExternalClientBuilder<C>
where C: RefUnwindSafe,

§

impl<C> Send for ExternalClientBuilder<C>
where C: Send,

§

impl<C> Sync for ExternalClientBuilder<C>
where C: Sync,

§

impl<C> Unpin for ExternalClientBuilder<C>
where C: Unpin,

§

impl<C> UnwindSafe for ExternalClientBuilder<C>
where C: UnwindSafe,

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
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

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

Initializes a with the given initializer. Read more
source§

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

Dereferences the given pointer. Read more
source§

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

Mutably dereferences the given pointer. Read more
source§

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.