ruma_events/secret_storage/
default_key.rs

1//! Types for the [`m.secret_storage.default_key`] event.
2//!
3//! [`m.secret_storage.default_key`]: https://spec.matrix.org/latest/client-server-api/#key-storage
4
5use serde::{Deserialize, Serialize};
6
7use crate::macros::EventContent;
8
9/// The payload for `DefaultKeyEvent`.
10#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
11#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
12#[ruma_event(type = "m.secret_storage.default_key", kind = GlobalAccountData)]
13pub struct SecretStorageDefaultKeyEventContent {
14    /// The ID of the default key.
15    #[serde(rename = "key")]
16    pub key_id: String,
17}
18
19impl SecretStorageDefaultKeyEventContent {
20    /// Create a new [`SecretStorageDefaultKeyEventContent`] with the given key ID.
21    ///
22    /// Uploading this to the account data will mark the secret storage key with the given key ID as
23    /// the default key.
24    pub fn new(key_id: String) -> Self {
25        Self { key_id }
26    }
27}