1
0
Fork 0
ruma/crates/ruma-events/tests/it/ui/10-content-wildcard.rs
Kévin Commaille 993ba20ab2 events: Add IsPrefix associated type to StaticEventContent
To identify when the statically-known part of the event type is a
prefix.
2025-07-03 22:08:27 +02:00

22 lines
647 B
Rust

#![allow(unexpected_cfgs)]
use ruma_macros::EventContent;
use serde::Serialize;
#[derive(Clone, Debug, Serialize, EventContent)]
#[ruma_event(type = "m.macro.test.*", kind = GlobalAccountData)]
pub struct MacroTestContent {
#[ruma_event(type_fragment)]
pub frag: String,
}
fn main() {
use ruma_events::{BooleanType, GlobalAccountDataEventContent, StaticEventContent};
assert_eq!(MacroTestContent::TYPE, "m.macro.test.");
assert!(<MacroTestContent as StaticEventContent>::IsPrefix::as_bool());
assert_eq!(
MacroTestContent { frag: "foo".to_owned() }.event_type().to_string(),
"m.macro.test.foo"
);
}