pub async fn encrypt(&self, content: AnyMessageEventContent) -> EncryptedEventContent {
        let json_content = json!({
            "content": content,
            "room_id": &*self.room_id,
            "type": content.event_type(),
        });

        let plaintext = cjson::to_string(&json_content).unwrap_or_else(|_| {
            panic!(format!(
                "Can't serialize {} to canonical JSON",
                json_content
            ))
        });

        let ciphertext = self.encrypt_helper(plaintext).await;

        EncryptedEventContent::MegolmV1AesSha2(
            matrix_sdk_common::events::room::encrypted::MegolmV1AesSha2ContentInit {
                ciphertext,
                sender_key: self.account_identity_keys.curve25519().to_owned(),
                session_id: self.session_id().to_owned(),
                device_id: (&*self.device_id).to_owned(),
            }
            .into(),
        )
    }
/// Encrypt a room message for the given room.
///
/// Beware that a group session needs to be shared before this method can be
/// called using the `share_group_session()` method.
///
/// Since group sessions can expire or become invalid if the room membership
/// changes client authors should check with the
/// `should_share_group_session()` method if a new group session needs to
/// be shared.
///
/// # Arguments
///
/// * `content` - The plaintext content of the message that should be
/// encrypted.
///
/// # Panics
///
/// Panics if the content can't be serialized.
Encrypt a room message for the given room.
Beware that a group session needs to be shared before this method can be
called using the `share_group_session()` method.

Since group sessions can expire or become invalid if the room membership
changes client authors should check with the
`should_share_group_session()` method if a new group session needs to
be shared.
Encrypt a room message for the given room . Beware that a group session needs to be shared before this method can be called using the ` share_group_session () ` method . Since group sessions can expire or become invalid if the room membership changes client authors should check with the ` should_share_group_session () ` method if a new group session needs to be shared .
pub async fn encrypt(&self, content: AnyMessageEventContent) -> EncryptedEventContent {
        let json_content = json!({
            "content": content,
            "room_id": &*self.room_id,
            "type": content.event_type(),
        });
        let plaintext = cjson::to_string(&json_content).unwrap_or_else(|_| {
            panic!(format!(
                "Can't serialize {} to canonical JSON",
                json_content
            ))
        });
        let ciphertext = self.encrypt_helper(plaintext).await;
        EncryptedEventContent::MegolmV1AesSha2(
            matrix_sdk_common::events::room::encrypted::MegolmV1AesSha2ContentInit {
                ciphertext,
                sender_key: self.account_identity_keys.curve25519().to_owned(),
                session_id: self.session_id().to_owned(),
                device_id: (&*self.device_id).to_owned(),
            }
            .into(),
        )
    }
pub async fn encrypt ( & self , content : AnyMessageEventContent ) -> EncryptedEventContent { let json_content = json ! ( { " " content " " self room_id " " content event_type ( ) } ) ; let plaintext = cjson :: to_string ( & json_content ) . unwrap_or_else ( | _ | { panic ! ( format ( " " json_content ) ) } ) ; let ciphertext = self . encrypt_helper ( plaintext ) . await ; EncryptedEventContent :: MegolmV1AesSha2 ( matrix_sdk_common :: events :: room :: encrypted :: MegolmV1AesSha2ContentInit { ciphertext , sender_key : self . account_identity_keys . curve25519 ( ) . to_owned ( ) , session_id : self . session_id ( ) . to_owned ( ) , device_id : ( & * self . device_id ) . to_owned ( ) , } . into ( ) , ) }
Encrypt a room message for the given room.
Encrypt a room message for the given room .
&self
content
AnyMessageEventContent
&self
content
AnyMessageEventContent
panics
Panics if the content can't be serialized.
Panics if the content can ' t be serialized .