core_crypto/mls/conversation/immutable_conversation/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use super::{ConversationWithMls, MlsConversation, Result};
use crate::prelude::MlsCentral;

/// An ImmutableConversation wraps a `MlsConversation`.
///
/// It only exposes the read-only interface of the conversation.
pub struct ImmutableConversation {
    inner: MlsConversation,
    central: MlsCentral,
}

#[cfg_attr(target_family = "wasm", async_trait::async_trait(?Send))]
#[cfg_attr(not(target_family = "wasm"), async_trait::async_trait)]
impl<'inner> ConversationWithMls<'inner> for ImmutableConversation {
    type Central = MlsCentral;

    type Conversation = &'inner MlsConversation;

    async fn central(&self) -> Result<MlsCentral> {
        Ok(self.central.clone())
    }

    async fn conversation(&'inner self) -> &'inner MlsConversation {
        &self.inner
    }
}

impl ImmutableConversation {
    pub(crate) fn new(inner: MlsConversation, central: MlsCentral) -> Self {
        Self { inner, central }
    }
}