ruma-events 0.34.0

Serializable types for the events in the Matrix specification.
Documentation
//! Types for the [`m.secret_storage.default_key`] event.
//!
//! [`m.secret_storage.default_key`]: https://spec.matrix.org/v1.18/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(ruma_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 }
    }
}