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
pub fn server_ts(self, ts: u64) -> Self
Sourcepub fn event<E: StaticEventContent<IsPrefix = False>>(
&self,
content: E,
) -> EventBuilder<E>
pub fn event<E: StaticEventContent<IsPrefix = False>>( &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 emote(
&self,
content: impl Into<String>,
) -> EventBuilder<RoomMessageEventContent>
pub fn emote( &self, content: impl Into<String>, ) -> EventBuilder<RoomMessageEventContent>
Create a new plain emote m.room.message.
Sourcepub fn encrypted(
&self,
ciphertext: impl Into<String>,
sender_key: impl Into<String>,
device_id: impl Into<OwnedDeviceId>,
session_id: impl Into<String>,
) -> EventBuilder<RoomEncryptedEventContent>
pub fn encrypted( &self, ciphertext: impl Into<String>, sender_key: impl Into<String>, device_id: impl Into<OwnedDeviceId>, session_id: impl Into<String>, ) -> EventBuilder<RoomEncryptedEventContent>
Create a new m.room.encrypted event using the m.megolm.v1.aes-sha2
algorithm.
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::{
SyncStateEvent,
room::member::{MembershipState, RoomMemberEventContent},
},
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 room_tombstone(
&self,
body: impl Into<String>,
replacement: &RoomId,
) -> EventBuilder<RoomTombstoneEventContent>
pub fn room_tombstone( &self, body: impl Into<String>, replacement: &RoomId, ) -> EventBuilder<RoomTombstoneEventContent>
Create a tombstone state event for the room.
Sourcepub fn room_topic(
&self,
topic: impl Into<String>,
) -> EventBuilder<RoomTopicEventContent>
pub fn room_topic( &self, topic: impl Into<String>, ) -> EventBuilder<RoomTopicEventContent>
Create a state event for the topic.
Sourcepub fn room_name(
&self,
name: impl Into<String>,
) -> EventBuilder<RoomNameEventContent>
pub fn room_name( &self, name: impl Into<String>, ) -> EventBuilder<RoomNameEventContent>
Create a state event for the room name.
Sourcepub fn room_avatar(&self) -> EventBuilder<RoomAvatarEventContent>
pub fn room_avatar(&self) -> EventBuilder<RoomAvatarEventContent>
Create an empty state event for the room avatar.
Sourcepub fn room_encryption(&self) -> EventBuilder<RoomEncryptionEventContent>
pub fn room_encryption(&self) -> EventBuilder<RoomEncryptionEventContent>
Create a state event for room encryption with recommended defaults.
This creates an m.room.encryption event with the
m.megolm.v1.aes-sha2 algorithm and recommended rotation settings.
Sourcepub fn room_history_visibility(
&self,
visibility: HistoryVisibility,
) -> EventBuilder<RoomHistoryVisibilityEventContent>
pub fn room_history_visibility( &self, visibility: HistoryVisibility, ) -> EventBuilder<RoomHistoryVisibilityEventContent>
Create a room history visibility state event.
This creates an m.room.history_visibility event with the given
visibility setting.
Sourcepub fn room_join_rules(
&self,
join_rule: JoinRule,
) -> EventBuilder<RoomJoinRulesEventContent>
pub fn room_join_rules( &self, join_rule: JoinRule, ) -> EventBuilder<RoomJoinRulesEventContent>
Create a room join rules state event.
This creates an m.room.join_rules event with the given join rule.
Sourcepub fn room_pinned_events(
&self,
pinned: Vec<OwnedEventId>,
) -> EventBuilder<RoomPinnedEventsEventContent>
pub fn room_pinned_events( &self, pinned: Vec<OwnedEventId>, ) -> EventBuilder<RoomPinnedEventsEventContent>
Create a state event for the room’s pinned events.
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::{SyncStateEvent, member_hints::MemberHintsEventContent},
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: impl Into<String>,
) -> EventBuilder<ReactionEventContent>
pub fn reaction( &self, event_id: &EventId, annotation: impl Into<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 live redaction for the given event id.
Note: this is not a redacted event, but a redaction event, that will cause another event to be redacted.
Sourcepub fn redacted<T: StaticEventContent<IsPrefix = False> + RedactedMessageLikeEventContent>(
&self,
redacter: &UserId,
content: T,
) -> EventBuilder<T>
pub fn redacted<T: StaticEventContent<IsPrefix = False> + RedactedMessageLikeEventContent>( &self, redacter: &UserId, content: T, ) -> EventBuilder<T>
Create a redacted event, with extra information in the unsigned section about the redaction itself.
Sourcepub fn redacted_state<T: StaticEventContent<IsPrefix = False> + RedactedStateEventContent>(
&self,
redacter: &UserId,
state_key: impl Into<String>,
content: T,
) -> EventBuilder<T>
pub fn redacted_state<T: StaticEventContent<IsPrefix = False> + RedactedStateEventContent>( &self, redacter: &UserId, state_key: impl Into<String>, content: T, ) -> EventBuilder<T>
Create a redacted state event, with extra information in the unsigned section about the redaction itself.
Sourcepub fn poll_start(
&self,
fallback_text: impl Into<String>,
poll_question: impl Into<String>,
answers: Vec<impl Into<String>>,
) -> EventBuilder<UnstablePollStartEventContent>
pub fn poll_start( &self, fallback_text: 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,
answers: Vec<impl Into<String>>,
poll_start_id: &EventId,
) -> EventBuilder<UnstablePollResponseEventContent>
pub fn poll_response( &self, answers: Vec<impl Into<String>>, poll_start_id: &EventId, ) -> EventBuilder<UnstablePollResponseEventContent>
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<UnstablePollEndEventContent>
pub fn poll_end( &self, content: impl Into<String>, poll_start_id: &EventId, ) -> EventBuilder<UnstablePollEndEventContent>
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 gallery(
&self,
body: String,
filename: String,
url: OwnedMxcUri,
) -> EventBuilder<RoomMessageEventContent>
pub fn gallery( &self, body: String, filename: String, url: OwnedMxcUri, ) -> EventBuilder<RoomMessageEventContent>
Create a gallery event containing a single plain (unencrypted) image referencing the given MXC ID.
Sourcepub fn typing(&self, user_ids: Vec<&UserId>) -> EventBuilder<TypingEventContent>
pub fn typing(&self, user_ids: Vec<&UserId>) -> EventBuilder<TypingEventContent>
Create a typing notification event.
Sourcepub fn read_receipts(&self) -> ReadReceiptBuilder<'_>
pub fn read_receipts(&self) -> ReadReceiptBuilder<'_>
Create a read receipt event.
Sourcepub fn create(
&self,
creator_user_id: &UserId,
room_version: RoomVersionId,
) -> EventBuilder<RoomCreateEventContent>
pub fn create( &self, creator_user_id: &UserId, room_version: RoomVersionId, ) -> EventBuilder<RoomCreateEventContent>
Create a new m.room.create event.
Sourcepub fn power_levels(
&self,
map: &mut BTreeMap<OwnedUserId, Int>,
) -> EventBuilder<RoomPowerLevelsEventContent>
pub fn power_levels( &self, map: &mut BTreeMap<OwnedUserId, Int>, ) -> EventBuilder<RoomPowerLevelsEventContent>
Create a new m.room.power_levels event.
Sourcepub fn default_power_levels(&self) -> EventBuilder<RoomPowerLevelsEventContent>
pub fn default_power_levels(&self) -> EventBuilder<RoomPowerLevelsEventContent>
Create a new m.room.power_levels event with default values.
Sourcepub fn server_acl(
&self,
allow_ip_literals: bool,
allow: Vec<String>,
deny: Vec<String>,
) -> EventBuilder<RoomServerAclEventContent>
pub fn server_acl( &self, allow_ip_literals: bool, allow: Vec<String>, deny: Vec<String>, ) -> EventBuilder<RoomServerAclEventContent>
Create a new m.room.server_acl event.
Sourcepub fn canonical_alias(
&self,
alias: Option<OwnedRoomAliasId>,
alt_aliases: Vec<OwnedRoomAliasId>,
) -> EventBuilder<RoomCanonicalAliasEventContent>
pub fn canonical_alias( &self, alias: Option<OwnedRoomAliasId>, alt_aliases: Vec<OwnedRoomAliasId>, ) -> EventBuilder<RoomCanonicalAliasEventContent>
Create a new m.room.canonical_alias event.
Sourcepub fn beacon(
&self,
beacon_info_event_id: OwnedEventId,
latitude: f64,
longitude: f64,
uncertainty: u32,
ts: Option<MilliSecondsSinceUnixEpoch>,
) -> EventBuilder<BeaconEventContent>
pub fn beacon( &self, beacon_info_event_id: OwnedEventId, latitude: f64, longitude: f64, uncertainty: u32, ts: Option<MilliSecondsSinceUnixEpoch>, ) -> EventBuilder<BeaconEventContent>
Create a new org.matrix.msc3672.beacon event.
use matrix_sdk_test::event_factory::EventFactory;
use ruma::{
MilliSecondsSinceUnixEpoch,
events::{MessageLikeEvent, beacon::BeaconEventContent},
owned_event_id, room_id,
serde::Raw,
user_id,
};
let factory = EventFactory::new().room(room_id!("!test:localhost"));
let event: Raw<MessageLikeEvent<BeaconEventContent>> = factory
.beacon(
owned_event_id!("$123456789abc:localhost"),
10.1,
15.2,
5,
Some(MilliSecondsSinceUnixEpoch(1000u32.into())),
)
.sender(user_id!("@alice:localhost"))
.into_raw();Sourcepub fn beacon_info(
&self,
description: Option<String>,
duration: Duration,
live: bool,
ts: Option<MilliSecondsSinceUnixEpoch>,
) -> EventBuilder<BeaconInfoEventContent>
pub fn beacon_info( &self, description: Option<String>, duration: Duration, live: bool, ts: Option<MilliSecondsSinceUnixEpoch>, ) -> EventBuilder<BeaconInfoEventContent>
Create a new org.matrix.msc3672.beacon_info state event.
§Arguments
description- An optional human-readable label for the sharing session.duration- How long the location share is active.live- Whether the sharing session is active. Passtrueto start andfalseto stop.ts- The start timestamp; ifNonethe current time is used.
§Example
use std::time::Duration;
use matrix_sdk_test::event_factory::EventFactory;
use ruma::{room_id, user_id};
let factory = EventFactory::new().room(room_id!("!test:localhost"));
let event = factory
.beacon_info(None, Duration::from_secs(60), true, None)
.sender(user_id!("@alice:localhost"))
.state_key(user_id!("@alice:localhost"));Sourcepub fn sticker(
&self,
body: impl Into<String>,
info: ImageInfo,
url: OwnedMxcUri,
) -> EventBuilder<StickerEventContent>
pub fn sticker( &self, body: impl Into<String>, info: ImageInfo, url: OwnedMxcUri, ) -> EventBuilder<StickerEventContent>
Create a new m.sticker event.
Sourcepub fn call_invite(
&self,
call_id: OwnedVoipId,
lifetime: UInt,
offer: SessionDescription,
version: VoipVersionId,
) -> EventBuilder<CallInviteEventContent>
pub fn call_invite( &self, call_id: OwnedVoipId, lifetime: UInt, offer: SessionDescription, version: VoipVersionId, ) -> EventBuilder<CallInviteEventContent>
Create a new m.call.invite event.
Sourcepub fn rtc_notification(
&self,
notification_type: NotificationType,
) -> EventBuilder<RtcNotificationEventContent>
pub fn rtc_notification( &self, notification_type: NotificationType, ) -> EventBuilder<RtcNotificationEventContent>
Create a new m.rtc.notification event.
pub fn call_decline( &self, notification_event_id: &EventId, ) -> EventBuilder<RtcDeclineEventContent>
Sourcepub fn direct(&self) -> EventBuilder<DirectEventContent>
pub fn direct(&self) -> EventBuilder<DirectEventContent>
Create a new m.direct global account data event.
Sourcepub fn ignored_user_list(
&self,
users: impl IntoIterator<Item = OwnedUserId>,
) -> EventBuilder<IgnoredUserListEventContent>
pub fn ignored_user_list( &self, users: impl IntoIterator<Item = OwnedUserId>, ) -> EventBuilder<IgnoredUserListEventContent>
Create a new m.ignored_user_list global account data event.
Sourcepub fn push_rules(&self, rules: Ruleset) -> EventBuilder<PushRulesEventContent>
pub fn push_rules(&self, rules: Ruleset) -> EventBuilder<PushRulesEventContent>
Create a new m.push_rules global account data event.
Sourcepub fn space_child(
&self,
parent: OwnedRoomId,
child: OwnedRoomId,
) -> EventBuilder<SpaceChildEventContent>
pub fn space_child( &self, parent: OwnedRoomId, child: OwnedRoomId, ) -> EventBuilder<SpaceChildEventContent>
Create a new m.space.child state event.
Sourcepub fn space_parent(
&self,
parent: OwnedRoomId,
child: OwnedRoomId,
) -> EventBuilder<SpaceParentEventContent>
pub fn space_parent( &self, parent: OwnedRoomId, child: OwnedRoomId, ) -> EventBuilder<SpaceParentEventContent>
Create a new m.space.parent state event.
Sourcepub fn custom_message_like_event(
&self,
) -> EventBuilder<CustomMessageLikeEventContent>
pub fn custom_message_like_event( &self, ) -> EventBuilder<CustomMessageLikeEventContent>
Create a new rs.matrix-sdk.custom.test custom event
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.
Sourcepub fn global_account_data<C>(&self, content: C) -> EventBuilder<C>where
C: GlobalAccountDataEventContent + StaticEventContent<IsPrefix = False>,
pub fn global_account_data<C>(&self, content: C) -> EventBuilder<C>where
C: GlobalAccountDataEventContent + StaticEventContent<IsPrefix = False>,
Create a new global account data event of the given C content type.
Sourcepub fn room_account_data<C>(&self, content: C) -> EventBuilder<C>where
C: RoomAccountDataEventContent + StaticEventContent<IsPrefix = False>,
pub fn room_account_data<C>(&self, content: C) -> EventBuilder<C>where
C: RoomAccountDataEventContent + StaticEventContent<IsPrefix = False>,
Create a new room account data event of the given C content type.
Sourcepub fn fully_read(
&self,
event_id: &EventId,
) -> EventBuilder<FullyReadEventContent>
pub fn fully_read( &self, event_id: &EventId, ) -> EventBuilder<FullyReadEventContent>
Create a new m.fully_read room account data event.
Sourcepub fn marked_unread(
&self,
unread: bool,
) -> EventBuilder<MarkedUnreadEventContent>
pub fn marked_unread( &self, unread: bool, ) -> EventBuilder<MarkedUnreadEventContent>
Create a new m.marked_unread room account data event.
Sourcepub fn tag(&self, tags: Tags) -> EventBuilder<TagEventContent>
pub fn tag(&self, tags: Tags) -> EventBuilder<TagEventContent>
Create a new m.tag room account data event with the given tags.
Sourcepub fn space_order(&self, order: &str) -> EventBuilder<SpaceOrderEventContent>
pub fn space_order(&self, order: &str) -> EventBuilder<SpaceOrderEventContent>
Create a new m.space_order room account data event with the given
order.
Sourcepub fn presence(&self, state: PresenceState) -> PresenceBuilder
pub fn presence(&self, state: PresenceState) -> PresenceBuilder
Create a new m.presence event.
This is a special event type that has its own structure different from regular Matrix events.
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 UnsafeUnpin 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> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<> Read more