[−][src]Struct matrix_sdk_test::EventBuilder
The EventBuilder
struct can be used to easily generate valid sync responses for testing.
These can be then fed into either Client
or Room
.
It supports generated a number of canned events, such as a member entering a room, his power
level and display name changing and similar. It also supports insertion of custom events in the
form of EventsJson
values.
Important You must use the same builder when sending multiple sync responses to
a single client. Otherwise, the subsequent responses will be ignored by the client because
the next_batch
sync token will not be rotated properly.
Example usage
use matrix_sdk_test::{EventBuilder, EventsJson}; let mut builder = EventBuilder::new(); // response1 now contains events that add an example member to the room and change their power // level let response1 = builder .add_room_event(EventsJson::Member) .add_room_event(EventsJson::PowerLevels) .build_sync_response(); // response2 is now empty (nothing changed) let response2 = builder.build_sync_response(); // response3 contains a display name change for member example let response3 = builder .add_room_event(EventsJson::MemberNameChange) .build_sync_response();
Implementations
impl EventBuilder
[src]
pub fn new() -> Self
[src]
pub fn add_ephemeral(&mut self, json: EventsJson) -> &mut Self
[src]
Add an event to the room events Vec
.
pub fn add_account(&mut self, json: EventsJson) -> &mut Self
[src]
Add an event to the room events Vec
.
pub fn add_room_event(&mut self, json: EventsJson) -> &mut Self
[src]
Add an event to the room events Vec
.
pub fn add_custom_joined_event(
&mut self,
room_id: &RoomId,
event: Value
) -> &mut Self
[src]
&mut self,
room_id: &RoomId,
event: Value
) -> &mut Self
pub fn add_custom_invited_event(
&mut self,
room_id: &RoomId,
event: Value
) -> &mut Self
[src]
&mut self,
room_id: &RoomId,
event: Value
) -> &mut Self
pub fn add_custom_left_event(
&mut self,
room_id: &RoomId,
event: Value
) -> &mut Self
[src]
&mut self,
room_id: &RoomId,
event: Value
) -> &mut Self
pub fn add_state_event(&mut self, json: EventsJson) -> &mut Self
[src]
Add a state event to the state events Vec
.
pub fn add_presence_event(&mut self, json: EventsJson) -> &mut Self
[src]
Add an presence event to the presence events Vec
.
pub fn build_sync_response(&mut self) -> SyncResponse
[src]
Builds a SyncResponse
containing the events we queued so far. The next response returned
by build_sync_response
will then be empty if no further events were queued.
pub fn clear(&mut self)
[src]
Trait Implementations
impl Default for EventBuilder
[src]
pub fn default() -> EventBuilder
[src]
Auto Trait Implementations
impl RefUnwindSafe for EventBuilder
[src]
impl Send for EventBuilder
[src]
impl Sync for EventBuilder
[src]
impl Unpin for EventBuilder
[src]
impl UnwindSafe for EventBuilder
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,