1
0
Fork 0
ruma/crates/ruma-events/tests/it/ui/07-enum-sanity-check.rs
Kévin Commaille 02d6be8ec5 common: Add hidden macro to generate PrivOwnedStr structs
This avoids to duplicate the boilerplate between crates, especially when
exposing the struct via uniffi.
2026-02-25 15:00:29 +01:00

43 lines
1.4 KiB
Rust

#![allow(unexpected_cfgs)]
#[cfg(feature = "unstable-uniffi")]
uniffi::setup_scaffolding!();
use ruma_macros::event_enum;
event_enum! {
/// Any global account data event.
enum GlobalAccountData {
#[ruma_enum(alias = "io.ruma.direct")]
"m.direct" => ruma_events::direct,
#[ruma_enum(alias = "m.identity_server")]
"io.ruma.identity_server" => ruma_events::identity_server,
#[cfg(test)]
"m.ignored_user_list" => ruma_events::ignored_user_list,
// Doesn't actually have a wildcard, but this should work as a wildcard test
"m.push_rules.*" => ruma_events::push_rules,
#[cfg(any())]
"m.ruma_test" => ruma_events::ruma_test,
}
}
fn main() {
assert_eq!(GlobalAccountDataEventType::from("m.direct"), GlobalAccountDataEventType::Direct);
assert_eq!(
GlobalAccountDataEventType::from("io.ruma.direct"),
GlobalAccountDataEventType::Direct
);
assert_eq!(GlobalAccountDataEventType::Direct.to_cow_str(), "m.direct");
assert_eq!(
GlobalAccountDataEventType::from("m.identity_server"),
GlobalAccountDataEventType::IdentityServer
);
assert_eq!(
GlobalAccountDataEventType::from("io.ruma.identity_server"),
GlobalAccountDataEventType::IdentityServer
);
assert_eq!(GlobalAccountDataEventType::IdentityServer.to_cow_str(), "io.ruma.identity_server");
}
ruma_common::priv_owned_str!(uniffi);