core_crypto/mls/conversation/immutable_conversation/
mod.rs

1use super::{ConversationWithMls, MlsConversation, Result};
2use crate::prelude::MlsCentral;
3
4/// An ImmutableConversation wraps a `MlsConversation`.
5///
6/// It only exposes the read-only interface of the conversation.
7pub struct ImmutableConversation {
8    inner: MlsConversation,
9    central: MlsCentral,
10}
11
12#[cfg_attr(target_family = "wasm", async_trait::async_trait(?Send))]
13#[cfg_attr(not(target_family = "wasm"), async_trait::async_trait)]
14impl<'inner> ConversationWithMls<'inner> for ImmutableConversation {
15    type Central = MlsCentral;
16
17    type Conversation = &'inner MlsConversation;
18
19    async fn central(&self) -> Result<MlsCentral> {
20        Ok(self.central.clone())
21    }
22
23    async fn conversation(&'inner self) -> &'inner MlsConversation {
24        &self.inner
25    }
26}
27
28impl ImmutableConversation {
29    pub(crate) fn new(inner: MlsConversation, central: MlsCentral) -> Self {
30        Self { inner, central }
31    }
32}