ruma_events/secret/
push.rs

1//! Types for the [`io.element.msc4385.secret.push`] event.
2//!
3//! [`io.element.msc4385.secret.push`]: https://github.com/matrix-org/matrix-spec-proposals/pull/4385
4
5use std::fmt;
6
7use ruma_macros::EventContent;
8use serde::{Deserialize, Serialize};
9
10use super::request::SecretName;
11
12/// The content of an `m.secret.push` event.
13///
14/// An event sent by a client to push a secret with another device, without needing an
15/// `m.secret.request` event.
16///
17/// It must be encrypted as an `m.room.encrypted` event, then sent as a to-device event.
18#[derive(Clone, Deserialize, Serialize, EventContent)]
19#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
20#[ruma_event(type = "io.element.msc4385.secret.push", kind = ToDevice)]
21pub struct ToDeviceSecretPushEventContent {
22    /// The name of the secret.
23    pub name: SecretName,
24
25    /// The contents of the secret.
26    pub secret: String,
27}
28
29impl ToDeviceSecretPushEventContent {
30    /// Creates a new `SecretPushEventContent` with the given name and secret.
31    pub fn new(name: SecretName, secret: String) -> Self {
32        Self { name, secret }
33    }
34}
35
36impl fmt::Debug for ToDeviceSecretPushEventContent {
37    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38        f.debug_struct("ToDeviceSecretPushEventContent")
39            .field("name", &self.name)
40            .finish_non_exhaustive()
41    }
42}