mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-06 23:15:08 -04:00
refactor(tests): Allow converting EventBuilder to state
This commit is contained in:
@@ -57,8 +57,9 @@ use ruma::{
|
||||
topic::RoomTopicEventContent,
|
||||
},
|
||||
typing::TypingEventContent,
|
||||
AnySyncTimelineEvent, AnyTimelineEvent, BundledMessageLikeRelations, EventContent,
|
||||
RedactedMessageLikeEventContent, RedactedStateEventContent,
|
||||
AnyStateEvent, AnySyncStateEvent, AnySyncTimelineEvent, AnyTimelineEvent,
|
||||
BundledMessageLikeRelations, EventContent, RedactedMessageLikeEventContent,
|
||||
RedactedStateEventContent, StateEventContent,
|
||||
},
|
||||
serde::Raw,
|
||||
server_name, EventId, Int, MilliSecondsSinceUnixEpoch, MxcUri, OwnedEventId, OwnedMxcUri,
|
||||
@@ -441,6 +442,24 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: StateEventContent> From<EventBuilder<E>> for Raw<AnySyncStateEvent>
|
||||
where
|
||||
E::EventType: Serialize,
|
||||
{
|
||||
fn from(val: EventBuilder<E>) -> Self {
|
||||
Raw::new(&val.construct_json(false)).unwrap().cast()
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: StateEventContent> From<EventBuilder<E>> for Raw<AnyStateEvent>
|
||||
where
|
||||
E::EventType: Serialize,
|
||||
{
|
||||
fn from(val: EventBuilder<E>) -> Self {
|
||||
Raw::new(&val.construct_json(true)).unwrap().cast()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct EventFactory {
|
||||
next_ts: AtomicU64,
|
||||
|
||||
Reference in New Issue
Block a user