From a317ae6340dad9385189412f074a65edea6149d9 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 9 Jun 2020 16:58:58 +0200 Subject: [PATCH] Add and re-export remaining event kinds --- src/event_kinds.rs | 65 ++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 5 +++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/event_kinds.rs b/src/event_kinds.rs index ce6fd495..a4423a80 100644 --- a/src/event_kinds.rs +++ b/src/event_kinds.rs @@ -47,6 +47,25 @@ pub struct MessageEvent { pub unsigned: UnsignedData, } +/// A message event without a `room_id`. +#[derive(Clone, Debug, Event)] +pub struct MessageEventStub { + /// Data specific to the event type. + pub content: C, + + /// The globally unique event identifier for the user who sent the event. + pub event_id: EventId, + + /// The fully-qualified ID of the user who sent this event. + pub sender: UserId, + + /// Timestamp in milliseconds on originating homeserver when this event was sent. + pub origin_server_ts: SystemTime, + + /// Additional key-value pairs not signed by the homeserver. + pub unsigned: UnsignedData, +} + /// State event. #[derive(Clone, Debug, Event)] pub struct StateEvent { @@ -78,6 +97,52 @@ pub struct StateEvent { pub unsigned: UnsignedData, } +/// A state event without a `room_id`. +#[derive(Clone, Debug, Event)] +pub struct StateEventStub { + /// Data specific to the event type. + pub content: C, + + /// The globally unique event identifier for the user who sent the event. + pub event_id: EventId, + + /// The fully-qualified ID of the user who sent this event. + pub sender: UserId, + + /// Timestamp in milliseconds on originating homeserver when this event was sent. + pub origin_server_ts: SystemTime, + + /// A unique key which defines the overwriting semantics for this piece of room state. + /// + /// This is often an empty string, but some events send a `UserId` to show + /// which user the event affects. + pub state_key: String, + + /// Optional previous content for this event. + pub prev_content: Option, + + /// Additional key-value pairs not signed by the homeserver. + pub unsigned: UnsignedData, +} + +/// A stripped-down state event, used for previews of rooms the user has been +/// invited to. +#[derive(Clone, Debug, Event)] +pub struct StrippedStateEventStub { + /// Data specific to the event type. + pub content: C, + + /// The fully-qualified ID of the user who sent this event. + pub sender: UserId, + + /// A unique key which defines the overwriting semantics for this piece of room state. + /// + /// This is often an empty string, but some events send a `UserId` to show + /// which user the event affects. + pub state_key: String, +} + +/// An event sent using send-to-device messaging. #[derive(Clone, Debug, Event)] pub struct ToDeviceEvent { /// Data specific to the event type. diff --git a/src/lib.rs b/src/lib.rs index 342a0159..da7912e8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -167,7 +167,10 @@ pub use self::{ }, custom::{CustomBasicEvent, CustomMessageEvent, CustomStateEvent}, error::{FromStrError, InvalidEvent, InvalidInput}, - event_kinds::{BasicEvent, EphemeralRoomEvent, MessageEvent, StateEvent}, + event_kinds::{ + BasicEvent, EphemeralRoomEvent, MessageEvent, MessageEventStub, StateEvent, StateEventStub, + StrippedStateEventStub, ToDeviceEvent, + }, event_type::EventType, json::EventJson, };