ruma_events/secret_storage/
default_key.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
//! Types for the [`m.secret_storage.default_key`] event.
//!
//! [`m.secret_storage.default_key`]: https://spec.matrix.org/latest/client-server-api/#key-storage

use serde::{Deserialize, Serialize};

use crate::macros::EventContent;

/// The payload for `DefaultKeyEvent`.
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.secret_storage.default_key", kind = GlobalAccountData)]
pub struct SecretStorageDefaultKeyEventContent {
    /// The ID of the default key.
    #[serde(rename = "key")]
    pub key_id: String,
}

impl SecretStorageDefaultKeyEventContent {
    /// Create a new [`SecretStorageDefaultKeyEventContent`] with the given key ID.
    ///
    /// Uploading this to the account data will mark the secret storage key with the given key ID as
    /// the default key.
    pub fn new(key_id: String) -> Self {
        Self { key_id }
    }
}