events: Add constructors for ParentEventContent and ChildEventContent

This commit is contained in:
Adam 2021-07-21 21:49:03 +02:00 committed by GitHub
parent 9a24f9edbd
commit 2e88e48eb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -14,7 +14,7 @@ use crate::StateEvent;
pub type ChildEvent = StateEvent<ChildEventContent>;
/// The payload for `ChildEvent`.
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[derive(Clone, Debug, Default, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.space.child", kind = State)]
pub struct ChildEventContent {
@ -44,6 +44,13 @@ pub struct ChildEventContent {
pub suggested: Option<bool>,
}
impl ChildEventContent {
/// Creates a new `ChildEventContent`.
pub fn new() -> Self {
Self::default()
}
}
#[cfg(test)]
mod tests {
use super::ChildEventContent;

View File

@ -32,6 +32,13 @@ pub struct ParentEventContent {
pub canonical: bool,
}
impl ParentEventContent {
/// Creates a new `ParentEventContent` with the given canonical flag.
pub fn new(canonical: bool) -> Self {
Self { via: None, canonical }
}
}
#[cfg(test)]
mod tests {
use super::ParentEventContent;