Skip to main content

Session

Struct Session 

Source
pub struct Session { /* private fields */ }
Expand description

A MLS Session enables a user device to communicate via the MLS protocol.

This closely maps to the Client term in RFC 9720, but we avoid that term to avoid ambiguity; Client is very overloaded with distinct meanings.

There is one Session per user per device. A session can contain many MLS groups/conversations.

It is cheap to clone a Session because everything heavy is wrapped inside an Arc.

Implementations§

Source§

impl Session

Source

pub async fn e2ei_is_pki_env_setup(&self) -> bool

Returns whether the E2EI PKI environment is setup (i.e. Root CA, Intermediates, CRLs)

Source

pub async fn e2ei_is_enabled( &self, cipher_suite: CipherSuite, ) -> Result<bool, Error>

Returns true if end-to-end-identity is enabled for the given cipher suite.

This is determined by checking for existence of credentials for the given cipher suite: If there are x509 (and optionally basic) credentials -> Ok(true) If there are no x509 but basic credentials -> Ok(false) If there are no credentials for the given cipher suite -> Err(CredentialNotFound)

Source

pub async fn e2ei_verify_group_state( &self, group_info: VerifiableGroupInfo, ) -> Result<E2eiConversationState, Error>

Verifies a Group state before joining it

Source

pub async fn get_credential_in_use( &self, group_info: VerifiableGroupInfo, credential_type: CredentialType, ) -> Result<E2eiConversationState, Error>

Gets the e2ei conversation state from a GroupInfo. Useful to check if the group has e2ei turned on or not before joining it.

Source§

impl Session

Source

pub async fn register_epoch_observer( &self, epoch_observer: Arc<dyn EpochObserver>, ) -> Result<(), Error>

Add an epoch observer to this session. (see EpochObserver).

This function should be called 0 or 1 times in a session’s lifetime. If called when an epoch observer already exists, this will return an error.

Source§

impl Session

Source

pub async fn register_history_observer( &self, history_observer: Arc<dyn HistoryObserver>, ) -> Result<()>

Add an history observer to this session. (see HistoryObserver).

This function should be called 0 or 1 times in a session’s lifetime. If called when an epoch observer already exists, this will return an error.

Source§

impl Session

Source

pub async fn get_keypackage_refs(&self) -> Result<Vec<KeypackageRef>, Error>

Get all KeypackageRefs in the database.

Source§

impl Session

Source

pub fn new( id: ClientId, crypto_provider: CryptoProvider, database: ImmutableDatabase, transport: Arc<dyn MlsTransport>, ) -> Self

Create a new Session

Source

pub async fn get_raw_conversation( &self, id: &ConversationIdRef, ) -> Result<Conversation, Error>

Get an immutable view of an MLS conversation.

This may be faster than crate::transaction_context::TransactionContext::conversation.

Source

pub async fn conversation_exists( &self, id: &ConversationIdRef, ) -> Result<bool, Error>

Checks if a given conversation id exists locally

Source

pub fn random_bytes(&self, len: usize) -> Result<Vec<u8>>

Generates a random byte array of the specified size

Source

pub fn database(&self) -> &ImmutableDatabase

Get read-only access to the database.

Source

pub async fn reseed(&self, seed: Option<EntropySeed>) -> Result<()>

Source

pub fn id(&self) -> ClientId

Retrieves the client’s client id. This is free-form and not inspected.

Trait Implementations§

Source§

impl Clone for Session

Source§

fn clone(&self) -> Session

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Session

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T