events: Add StaticEventContent trait
This commit is contained in:
parent
40d3b552da
commit
565793a37e
@ -363,6 +363,57 @@ pub trait RedactedMessageEventContent: RedactedEventContent {}
|
||||
/// Marker trait for the content of a redacted state event.
|
||||
pub trait RedactedStateEventContent: RedactedEventContent {}
|
||||
|
||||
/// Trait for abstracting over event content structs.
|
||||
///
|
||||
/// … but *not* enums which don't always have an event type and kind (e.g. message vs state) that's
|
||||
/// fixed / known at compile time.
|
||||
pub trait StaticEventContent: EventContent {
|
||||
/// The event's "kind".
|
||||
///
|
||||
/// See the type's documentation.
|
||||
const KIND: EventKind;
|
||||
|
||||
/// The event type.
|
||||
const TYPE: &'static str;
|
||||
}
|
||||
|
||||
/// The "kind" of an event.
|
||||
///
|
||||
/// This corresponds directly to the event content marker traits.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[non_exhaustive]
|
||||
pub enum EventKind {
|
||||
/// Global account data event kind.
|
||||
GlobalAccountData,
|
||||
|
||||
/// Room account data event kind.
|
||||
RoomAccountData,
|
||||
|
||||
/// Ephemeral room event kind.
|
||||
EphemeralRoomData,
|
||||
|
||||
/// Message event kind.
|
||||
///
|
||||
/// Since redacted / non-redacted message events are used in the same places bu have different
|
||||
/// sets of fields, these two variations are treated as two closely-related event kinds.
|
||||
Message {
|
||||
/// Redacted variation?
|
||||
redacted: bool,
|
||||
},
|
||||
|
||||
/// State event kind.
|
||||
///
|
||||
/// Since redacted / non-redacted state events are used in the same places bu have different
|
||||
/// sets of fields, these two variations are treated as two closely-related event kinds.
|
||||
State {
|
||||
/// Redacted variation?
|
||||
redacted: bool,
|
||||
},
|
||||
|
||||
/// To-device event kind.
|
||||
ToDevice,
|
||||
}
|
||||
|
||||
/// `HasDeserializeFields` is used in the code generated by the `Event` derive
|
||||
/// to aid in deserializing redacted events.
|
||||
#[doc(hidden)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user