test: EventBuilder<RoomCreateEventContent> can set predecessor.
This patch adds the `predecessor` and `no_predecessor` methods on `EventBuilder<RoomCreateEventContent>`. This is helpful to configure the `predecessor` field.
This commit is contained in:
@@ -41,7 +41,7 @@ use ruma::{
|
||||
room::{
|
||||
avatar::{self, RoomAvatarEventContent},
|
||||
canonical_alias::RoomCanonicalAliasEventContent,
|
||||
create::RoomCreateEventContent,
|
||||
create::{PreviousRoom, RoomCreateEventContent},
|
||||
encrypted::{EncryptedEventScheme, RoomEncryptedEventContent},
|
||||
member::{MembershipState, RoomMemberEventContent},
|
||||
message::{
|
||||
@@ -400,6 +400,20 @@ impl EventBuilder<UnstablePollStartEventContent> {
|
||||
}
|
||||
}
|
||||
|
||||
impl EventBuilder<RoomCreateEventContent> {
|
||||
/// Define the predecessor fields.
|
||||
pub fn predecessor(mut self, room_id: &RoomId, event_id: &EventId) -> Self {
|
||||
self.content.predecessor = Some(PreviousRoom::new(room_id.to_owned(), event_id.to_owned()));
|
||||
self
|
||||
}
|
||||
|
||||
/// Erase the predecessor if any.
|
||||
pub fn no_predecessor(mut self) -> Self {
|
||||
self.content.predecessor = None;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EventContent> From<EventBuilder<E>> for Raw<AnySyncTimelineEvent>
|
||||
where
|
||||
E::EventType: Serialize,
|
||||
|
||||
Reference in New Issue
Block a user