pub struct EventFactory { /* private fields */ }
Implementations§
Source§impl EventFactory
impl EventFactory
pub fn new() -> Self
pub fn room(self, room_id: &RoomId) -> Self
pub fn sender(self, sender: &UserId) -> Self
Sourcepub fn event<E: EventContent>(&self, content: E) -> EventBuilder<E>
pub fn event<E: EventContent>(&self, content: E) -> EventBuilder<E>
Create an event from any event content.
Sourcepub fn text_msg(
&self,
content: impl Into<String>,
) -> EventBuilder<RoomMessageEventContent>
pub fn text_msg( &self, content: impl Into<String>, ) -> EventBuilder<RoomMessageEventContent>
Create a new plain text m.room.message
.
Sourcepub fn member(&self, member: &UserId) -> EventBuilder<RoomMemberEventContent>
pub fn member(&self, member: &UserId) -> EventBuilder<RoomMemberEventContent>
Create a new m.room.member
event for the given member.
The given member will be used as the sender
as well as the state_key
of the m.room.member
event, unless the sender
was already using
EventFactory::sender()
, in that case only the state key will be
set to the given member
.
The membership
field of the content is set to
MembershipState::Join
.
use matrix_sdk_test::event_factory::EventFactory;
use ruma::{
events::{
room::member::{MembershipState, RoomMemberEventContent},
SyncStateEvent,
},
room_id,
serde::Raw,
user_id,
};
let factory = EventFactory::new().room(room_id!("!test:localhost"));
let event: Raw<SyncStateEvent<RoomMemberEventContent>> = factory
.member(user_id!("@alice:localhost"))
.display_name("Alice")
.into_raw();
Sourcepub fn member_hints(
&self,
service_members: BTreeSet<OwnedUserId>,
) -> EventBuilder<MemberHintsEventContent>
pub fn member_hints( &self, service_members: BTreeSet<OwnedUserId>, ) -> EventBuilder<MemberHintsEventContent>
Create a new m.member_hints
event with the given service members.
use std::collections::BTreeSet;
use matrix_sdk_test::event_factory::EventFactory;
use ruma::{
events::{member_hints::MemberHintsEventContent, SyncStateEvent},
owned_user_id, room_id,
serde::Raw,
user_id,
};
let factory = EventFactory::new().room(room_id!("!test:localhost"));
let event: Raw<SyncStateEvent<MemberHintsEventContent>> = factory
.member_hints(BTreeSet::from([owned_user_id!("@alice:localhost")]))
.sender(user_id!("@alice:localhost"))
.into_raw();
Sourcepub fn text_html(
&self,
plain: impl Into<String>,
html: impl Into<String>,
) -> EventBuilder<RoomMessageEventContent>
pub fn text_html( &self, plain: impl Into<String>, html: impl Into<String>, ) -> EventBuilder<RoomMessageEventContent>
Create a new plain/html m.room.message
.
Sourcepub fn notice(
&self,
content: impl Into<String>,
) -> EventBuilder<RoomMessageEventContent>
pub fn notice( &self, content: impl Into<String>, ) -> EventBuilder<RoomMessageEventContent>
Create a new plain notice m.room.message
.
Sourcepub fn reaction(
&self,
event_id: &EventId,
annotation: String,
) -> EventBuilder<ReactionEventContent>
pub fn reaction( &self, event_id: &EventId, annotation: String, ) -> EventBuilder<ReactionEventContent>
Add a reaction to an event.
Sourcepub fn redaction(
&self,
event_id: &EventId,
) -> EventBuilder<RoomRedactionEventContent>
pub fn redaction( &self, event_id: &EventId, ) -> EventBuilder<RoomRedactionEventContent>
Create a redaction for the given event id.
Sourcepub fn poll_start(
&self,
content: impl Into<String>,
poll_question: impl Into<String>,
answers: Vec<impl Into<String>>,
) -> EventBuilder<UnstablePollStartEventContent>
pub fn poll_start( &self, content: impl Into<String>, poll_question: impl Into<String>, answers: Vec<impl Into<String>>, ) -> EventBuilder<UnstablePollStartEventContent>
Create a poll start event given a text, the question and the possible answers.
Sourcepub fn poll_edit(
&self,
edited_event_id: &EventId,
poll_question: impl Into<String>,
answers: Vec<impl Into<String>>,
) -> EventBuilder<ReplacementUnstablePollStartEventContent>
pub fn poll_edit( &self, edited_event_id: &EventId, poll_question: impl Into<String>, answers: Vec<impl Into<String>>, ) -> EventBuilder<ReplacementUnstablePollStartEventContent>
Create a poll edit event given the new question and possible answers.
Sourcepub fn poll_response(
&self,
answer_id: impl Into<String>,
poll_start_id: &EventId,
) -> EventBuilder<PollResponseEventContent>
pub fn poll_response( &self, answer_id: impl Into<String>, poll_start_id: &EventId, ) -> EventBuilder<PollResponseEventContent>
Create a poll response with the given answer id and the associated poll start event id.
Sourcepub fn poll_end(
&self,
content: impl Into<String>,
poll_start_id: &EventId,
) -> EventBuilder<PollEndEventContent>
pub fn poll_end( &self, content: impl Into<String>, poll_start_id: &EventId, ) -> EventBuilder<PollEndEventContent>
Create a poll response with the given text and the associated poll start event id.
Sourcepub fn image(
&self,
filename: String,
url: OwnedMxcUri,
) -> EventBuilder<RoomMessageEventContent>
pub fn image( &self, filename: String, url: OwnedMxcUri, ) -> EventBuilder<RoomMessageEventContent>
Creates a plain (unencrypted) image event content referencing the given MXC ID.
Sourcepub fn set_next_ts(&self, value: u64)
pub fn set_next_ts(&self, value: u64)
Set the next server timestamp.
Timestamps will continue to increase by 1 (millisecond) from that value.
Trait Implementations§
Source§impl Debug for EventFactory
impl Debug for EventFactory
Source§impl Default for EventFactory
impl Default for EventFactory
Source§fn default() -> EventFactory
fn default() -> EventFactory
Auto Trait Implementations§
impl !Freeze for EventFactory
impl RefUnwindSafe for EventFactory
impl Send for EventFactory
impl Sync for EventFactory
impl Unpin for EventFactory
impl UnwindSafe for EventFactory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>