matrix_sdk_test/sync_builder/
invited_room.rs1use ruma::{
2 OwnedRoomId, RoomId, api::client::sync::sync_events::v3::InvitedRoom,
3 events::AnyStrippedStateEvent, serde::Raw,
4};
5
6use crate::DEFAULT_TEST_ROOM_ID;
7
8pub struct InvitedRoomBuilder {
9 pub(super) room_id: OwnedRoomId,
10 pub(super) inner: InvitedRoom,
11}
12
13impl InvitedRoomBuilder {
14 pub fn new(room_id: &RoomId) -> Self {
19 Self { room_id: room_id.to_owned(), inner: Default::default() }
20 }
21
22 pub fn room_id(&self) -> &RoomId {
24 &self.room_id
25 }
26
27 pub fn add_state_event(mut self, event: impl Into<Raw<AnyStrippedStateEvent>>) -> Self {
29 self.inner.invite_state.events.push(event.into());
30 self
31 }
32
33 pub fn add_state_bulk<I>(mut self, events: I) -> Self
35 where
36 I: IntoIterator<Item = Raw<AnyStrippedStateEvent>>,
37 {
38 self.inner.invite_state.events.extend(events);
39 self
40 }
41}
42
43impl Default for InvitedRoomBuilder {
44 fn default() -> Self {
45 Self::new(&DEFAULT_TEST_ROOM_ID)
46 }
47}