Implement Default for PowerLevelsEventContent

This commit is contained in:
Jonas Platte 2020-05-26 10:24:14 +02:00
parent d121192f69
commit d3ff2b65a7
No known key found for this signature in database
GPG Key ID: 7D261D771D915378

View File

@ -78,6 +78,26 @@ ruma_event! {
}, },
} }
} }
impl Default for PowerLevelsEventContent {
fn default() -> Self {
// events_default and users_default having a default of 0 while the others have a default
// of 50 is not an oversight, these defaults are from the Matrix specification.
Self {
ban: default_power_level(),
events: BTreeMap::new(),
events_default: Int::default(),
invite: default_power_level(),
kick: default_power_level(),
redact: default_power_level(),
state_default: default_power_level(),
users: BTreeMap::new(),
users_default: Int::default(),
notifications: NotificationPowerLevels::default(),
}
}
}
/// The power level requirements for specific notification types. /// The power level requirements for specific notification types.
#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)]
pub struct NotificationPowerLevels { pub struct NotificationPowerLevels {