Add more event kinds
This commit is contained in:
parent
315ac55d46
commit
283370ff2f
@ -11,7 +11,16 @@ use serde::{
|
|||||||
Serialize, Serializer,
|
Serialize, Serializer,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{MessageEventContent, RoomEventContent, StateEventContent, TryFromRaw, UnsignedData};
|
use crate::{
|
||||||
|
BasicEventContent, MessageEventContent, RoomEventContent, StateEventContent,
|
||||||
|
ToDeviceEventContent, TryFromRaw, UnsignedData,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// A basic event – one that consists only of it's type and the `content` object.
|
||||||
|
#[derive(Clone, Debug, Event)]
|
||||||
|
pub struct BasicEvent<C: BasicEventContent> {
|
||||||
|
pub content: C,
|
||||||
|
}
|
||||||
|
|
||||||
/// Message event.
|
/// Message event.
|
||||||
#[derive(Clone, Debug, Event)]
|
#[derive(Clone, Debug, Event)]
|
||||||
@ -22,7 +31,7 @@ pub struct MessageEvent<C: MessageEventContent> {
|
|||||||
/// The globally unique event identifier for the user who sent the event.
|
/// The globally unique event identifier for the user who sent the event.
|
||||||
pub event_id: EventId,
|
pub event_id: EventId,
|
||||||
|
|
||||||
/// Contains the fully-qualified ID of the user who sent this event.
|
/// The fully-qualified ID of the user who sent this event.
|
||||||
pub sender: UserId,
|
pub sender: UserId,
|
||||||
|
|
||||||
/// Timestamp in milliseconds on originating homeserver when this event was sent.
|
/// Timestamp in milliseconds on originating homeserver when this event was sent.
|
||||||
@ -44,7 +53,7 @@ pub struct StateEvent<C: StateEventContent> {
|
|||||||
/// The globally unique event identifier for the user who sent the event.
|
/// The globally unique event identifier for the user who sent the event.
|
||||||
pub event_id: EventId,
|
pub event_id: EventId,
|
||||||
|
|
||||||
/// Contains the fully-qualified ID of the user who sent this event.
|
/// The fully-qualified ID of the user who sent this event.
|
||||||
pub sender: UserId,
|
pub sender: UserId,
|
||||||
|
|
||||||
/// Timestamp in milliseconds on originating homeserver when this event was sent.
|
/// Timestamp in milliseconds on originating homeserver when this event was sent.
|
||||||
@ -65,3 +74,12 @@ pub struct StateEvent<C: StateEventContent> {
|
|||||||
/// Additional key-value pairs not signed by the homeserver.
|
/// Additional key-value pairs not signed by the homeserver.
|
||||||
pub unsigned: UnsignedData,
|
pub unsigned: UnsignedData,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Event)]
|
||||||
|
pub struct ToDeviceEvent<C: ToDeviceEventContent> {
|
||||||
|
/// Data specific to the event type.
|
||||||
|
pub content: C,
|
||||||
|
|
||||||
|
/// The fully-qualified ID of the user who sent this event.
|
||||||
|
pub sender: UserId,
|
||||||
|
}
|
||||||
|
@ -217,6 +217,9 @@ pub trait EventContent: Sized + Serialize {
|
|||||||
fn from_parts(event_type: &str, content: Box<RawJsonValue>) -> Result<Self, String>;
|
fn from_parts(event_type: &str, content: Box<RawJsonValue>) -> Result<Self, String>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Marker trait for the content of a basic event.
|
||||||
|
pub trait BasicEventContent: EventContent {}
|
||||||
|
|
||||||
/// Marker trait for the content of a room event.
|
/// Marker trait for the content of a room event.
|
||||||
pub trait RoomEventContent: EventContent {}
|
pub trait RoomEventContent: EventContent {}
|
||||||
|
|
||||||
@ -225,3 +228,6 @@ pub trait MessageEventContent: RoomEventContent {}
|
|||||||
|
|
||||||
/// Marker trait for the content of a state event.
|
/// Marker trait for the content of a state event.
|
||||||
pub trait StateEventContent: RoomEventContent {}
|
pub trait StateEventContent: RoomEventContent {}
|
||||||
|
|
||||||
|
/// Marker trait for event content types that are commonly sent using to-device messaging.
|
||||||
|
pub trait ToDeviceEventContent: EventContent {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user