ruwuma/crates/ruma-common/tests/events/ui/10-content-wildcard.rs
Kévin Commaille 97b212795a events: Create EventContentFromType
Implement it for:
- event contents that implement Deserialize
- event contents with event types with a suffix
- custom event contents
2023-01-10 11:37:31 +01:00

19 lines
442 B
Rust

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_common::events::EventContent;
assert_eq!(
MacroTestContent { frag: "foo".to_owned() }.event_type().to_string(),
"m.macro.test.foo"
);
}