matrix_sdk_test::event_factory

Struct EventBuilder

Source
pub struct EventBuilder<C: EventContent> { /* private fields */ }

Implementations§

Source§

impl<E: EventContent> EventBuilder<E>
where E::EventType: Serialize,

Source

pub fn room(self, room_id: &RoomId) -> Self

Source

pub fn sender(self, sender: &UserId) -> Self

Source

pub fn event_id(self, event_id: &EventId) -> Self

Source

pub fn no_event_id(self) -> Self

Source

pub fn server_ts(self, ts: impl TimestampArg) -> Self

Source

pub fn unsigned_transaction_id(self, transaction_id: &TransactionId) -> Self

Source

pub fn bundled_relations( self, relations: BundledMessageLikeRelations<Raw<AnySyncTimelineEvent>>, ) -> Self

Adds bundled relations to this event.

Ideally, we’d type-check that an event passed as a relation is the same type as this one, but it’s not trivial to do so because this builder is only generic on the event’s content, not the event type itself; doing so would require many changes, and this is testing code after all.

Source

pub fn state_key(self, state_key: impl Into<String>) -> Self

For state events manually created, define the state key.

For other state events created in the EventFactory, this is automatically filled upon creation or update of the events.

Source

pub fn into_raw<T>(self) -> Raw<T>

Build an event from the EventBuilder and convert it into a serialized and [Raw] event.

The generic argument T allows you to automatically cast the [Raw] event into any desired type.

Source

pub fn into_raw_timeline(self) -> Raw<AnyTimelineEvent>

Source

pub fn into_raw_sync(self) -> Raw<AnySyncTimelineEvent>

Source

pub fn into_event(self) -> TimelineEvent

Source§

impl EventBuilder<RoomEncryptedEventContent>

Source

pub fn into_utd_sync_timeline_event(self) -> TimelineEvent

Turn this event into a TimelineEvent representing a decryption failure

Source§

impl EventBuilder<RoomMessageEventContent>

Source

pub fn reply_to(self, event_id: &EventId) -> Self

Adds a reply relation to the current event.

Source

pub fn in_thread(self, root: &EventId, latest_thread_event: &EventId) -> Self

Adds a thread relation to the root event, setting the latest thread event id too.

Source

pub fn edit( self, edited_event_id: &EventId, new_content: RoomMessageEventContentWithoutRelation, ) -> Self

Adds a replacement relation to the current event, with the new content passed.

Source

pub fn caption( self, caption: Option<String>, formatted_caption: Option<FormattedBody>, ) -> Self

Adds a caption to a media event.

Will crash if the event isn’t a media room message.

Source§

impl EventBuilder<RoomMemberEventContent>

Source

pub fn membership(self, state: MembershipState) -> Self

Set the membership of the m.room.member event to the given [MembershipState].

The default is [MembershipState::Join].

Source

pub fn invited(self, invited_user: &UserId) -> Self

Set that the sender of this event invited the user passed as a parameter here.

Source

pub fn kicked(self, kicked_user: &UserId) -> Self

Set that the sender of this event kicked the user passed as a parameter here.

Source

pub fn banned(self, banned_user: &UserId) -> Self

Set that the sender of this event banned the user passed as a parameter here.

Source

pub fn display_name(self, display_name: impl Into<String>) -> Self

Set the display name of the m.room.member event.

Source

pub fn avatar_url(self, url: &MxcUri) -> Self

Set the avatar URL of the m.room.member event.

Source

pub fn reason(self, reason: impl Into<String>) -> Self

Set the reason field of the m.room.member event.

Source

pub fn previous(self, previous: impl Into<PreviousMembership>) -> Self

Set the previous membership state (in the unsigned section).

Source§

impl EventBuilder<RoomAvatarEventContent>

Source

pub fn url(self, url: &MxcUri) -> Self

Defines the URL for the room avatar.

Source

pub fn info(self, image: ImageInfo) -> Self

Defines the image info for the avatar.

Trait Implementations§

Source§

impl<C: Debug + EventContent> Debug for EventBuilder<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: EventContent> From<EventBuilder<E>> for Raw<AnySyncTimelineEvent>
where E::EventType: Serialize,

Source§

fn from(val: EventBuilder<E>) -> Self

Converts to this type from the input type.
Source§

impl<E: EventContent> From<EventBuilder<E>> for Raw<AnyTimelineEvent>
where E::EventType: Serialize,

Source§

fn from(val: EventBuilder<E>) -> Self

Converts to this type from the input type.
Source§

impl<E: EventContent> From<EventBuilder<E>> for TimelineEvent
where E::EventType: Serialize,

Source§

fn from(val: EventBuilder<E>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<C> Freeze for EventBuilder<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for EventBuilder<C>
where C: RefUnwindSafe,

§

impl<C> Send for EventBuilder<C>
where C: Send,

§

impl<C> Sync for EventBuilder<C>
where C: Sync,

§

impl<C> Unpin for EventBuilder<C>
where C: Unpin,

§

impl<C> UnwindSafe for EventBuilder<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

Source§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
Source§

fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<>
Source§

fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> AsyncTraitDeps for T

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> SendOutsideWasm for T
where T: Send,

Source§

impl<T> SyncOutsideWasm for T
where T: Sync,