1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use ruma::{
api::client::sync::sync_events::v3::InvitedRoom, events::AnyStrippedStateEvent, serde::Raw,
OwnedRoomId,
};
use super::StrippedStateTestEvent;
use crate::test_json;
pub struct InvitedRoomBuilder {
pub(super) room_id: OwnedRoomId,
pub(super) inner: InvitedRoom,
}
impl InvitedRoomBuilder {
pub fn new(room_id: impl Into<OwnedRoomId>) -> Self {
Self { room_id: room_id.into(), inner: Default::default() }
}
pub fn add_state_event(mut self, event: StrippedStateTestEvent) -> Self {
self.inner.invite_state.events.push(event.into_raw_event());
self
}
pub fn add_state_bulk<I>(mut self, events: I) -> Self
where
I: IntoIterator<Item = Raw<AnyStrippedStateEvent>>,
{
self.inner.invite_state.events.extend(events);
self
}
}
impl Default for InvitedRoomBuilder {
fn default() -> Self {
Self::new(test_json::DEFAULT_SYNC_ROOM_ID.to_owned())
}
}