Add a From SecretName implementation for GlobalAccountDataEventType

The secret names are reused as event types for the account data events
which get uploaded as part of the secret storage key/value store.
This commit is contained in:
Damir Jelić 2023-09-28 13:25:25 +02:00
parent 4ef6d1641b
commit 7474f3e9ef

View File

@ -6,7 +6,7 @@ use ruma_common::{serde::StringEnum, OwnedDeviceId, OwnedTransactionId};
use ruma_macros::EventContent; use ruma_macros::EventContent;
use serde::{ser::SerializeStruct, Deserialize, Serialize}; use serde::{ser::SerializeStruct, Deserialize, Serialize};
use crate::PrivOwnedStr; use crate::{GlobalAccountDataEventType, PrivOwnedStr};
/// The content of an `m.secret.request` event. /// The content of an `m.secret.request` event.
/// ///
@ -133,6 +133,12 @@ pub enum SecretName {
_Custom(PrivOwnedStr), _Custom(PrivOwnedStr),
} }
impl From<SecretName> for GlobalAccountDataEventType {
fn from(value: SecretName) -> Self {
GlobalAccountDataEventType::from(value.as_str())
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use assert_matches2::assert_matches; use assert_matches2::assert_matches;