diff --git a/crates/ruma-events-macros/src/event_content.rs b/crates/ruma-events-macros/src/event_content.rs index 3886e95a..61249c53 100644 --- a/crates/ruma-events-macros/src/event_content.rs +++ b/crates/ruma-events-macros/src/event_content.rs @@ -7,7 +7,7 @@ use syn::{ DeriveInput, Ident, LitStr, Token, }; -use crate::event_parse::EventKind; +use crate::event_parse::{EventKind, EventKindVariation}; mod kw { // This `content` field is kept when the event is redacted. @@ -154,12 +154,16 @@ pub fn expand_event_content( }); let marker_trait_impl = event_kind.map(|k| generate_marker_trait_impl(k, &input.ident, ruma_events)).transpose()?; + let type_aliases = event_kind + .map(|k| generate_event_type_aliases(k, &input.ident, &event_type.value(), ruma_events)) + .transpose()?; Ok(quote! { #redacted_event_content #event_content_impl #static_event_content_impl #marker_trait_impl + #type_aliases }) } @@ -319,6 +323,47 @@ fn generate_redacted_event_content( }) } +fn generate_event_type_aliases( + event_kind: &EventKind, + ident: &Ident, + event_type: &str, + ruma_events: &TokenStream, +) -> syn::Result { + if ident == "RedactionEventContent" { + return Ok(quote! {}); + } + + let ident_s = ident.to_string(); + let ev_type_s = ident_s.strip_suffix("Content").ok_or_else(|| { + syn::Error::new_spanned(ident, "Expected content struct name ending in `Content`") + })?; + + let ev_type = format_ident!("{}", ev_type_s); + let ev_type_doc = + format!("A `{}` event.\n\nFor more information, see [`{}`].", event_type, ident); + let ev_struct = format_ident!("{}", event_kind); + + let sync_type_alias = + event_kind.to_event_ident(&EventKindVariation::Sync).map(|sync_ev_struct| { + let sync_ev_type = format_ident!("Sync{}", ev_type_s); + let sync_ev_type_doc = format!( + "A `{}` event from a `sync_events` response.\n\nFor more information, see [`{}`].", + event_type, ident, + ); + + quote! { + #[doc = #sync_ev_type_doc] + pub type #sync_ev_type = #ruma_events::#sync_ev_struct<#ident>; + } + }); + + Ok(quote! { + #[doc = #ev_type_doc] + pub type #ev_type = #ruma_events::#ev_struct<#ident>; + #sync_type_alias + }) +} + fn generate_marker_trait_impl( event_kind: &EventKind, ident: &Ident, diff --git a/crates/ruma-events/src/call/answer.rs b/crates/ruma-events/src/call/answer.rs index 7e66c194..3ee99a60 100644 --- a/crates/ruma-events/src/call/answer.rs +++ b/crates/ruma-events/src/call/answer.rs @@ -5,12 +5,10 @@ use ruma_events_macros::EventContent; use serde::{Deserialize, Serialize}; use super::SessionDescription; -use crate::MessageEvent; +/// The content of an `m.call.answer` event. +/// /// This event is sent by the callee when they wish to answer the call. -pub type AnswerEvent = MessageEvent; - -/// The payload for `AnswerEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.call.answer", kind = Message)] diff --git a/crates/ruma-events/src/call/candidates.rs b/crates/ruma-events/src/call/candidates.rs index 0c61d0a6..ce3e2830 100644 --- a/crates/ruma-events/src/call/candidates.rs +++ b/crates/ruma-events/src/call/candidates.rs @@ -4,13 +4,10 @@ use js_int::UInt; use ruma_events_macros::EventContent; use serde::{Deserialize, Serialize}; -use crate::MessageEvent; - +/// The content of an `m.call.candidates` event. +/// /// This event is sent by callers after sending an invite and by the callee after answering. Its /// purpose is to give the other party additional ICE candidates to try using to communicate. -pub type CandidatesEvent = MessageEvent; - -/// The payload for `CandidatesEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.call.candidates", kind = Message)] diff --git a/crates/ruma-events/src/call/hangup.rs b/crates/ruma-events/src/call/hangup.rs index 1e8890a8..b91b8a36 100644 --- a/crates/ruma-events/src/call/hangup.rs +++ b/crates/ruma-events/src/call/hangup.rs @@ -5,13 +5,10 @@ use ruma_events_macros::EventContent; use ruma_serde::StringEnum; use serde::{Deserialize, Serialize}; -use crate::MessageEvent; - +/// The content of an `m.call.hangup` event. +/// /// Sent by either party to signal their termination of the call. This can be sent either once the /// call has has been established or before to abort the call. -pub type HangupEvent = MessageEvent; - -/// The payload for `HangupEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.call.hangup", kind = Message)] diff --git a/crates/ruma-events/src/call/invite.rs b/crates/ruma-events/src/call/invite.rs index 97ab421d..79b00c57 100644 --- a/crates/ruma-events/src/call/invite.rs +++ b/crates/ruma-events/src/call/invite.rs @@ -5,12 +5,10 @@ use ruma_events_macros::EventContent; use serde::{Deserialize, Serialize}; use super::SessionDescription; -use crate::MessageEvent; +/// The content of an `m.call.invite` event. +/// /// This event is sent by the caller when they wish to establish a call. -pub type InviteEvent = MessageEvent; - -/// The payload for `InviteEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.call.invite", kind = Message)] diff --git a/crates/ruma-events/src/direct.rs b/crates/ruma-events/src/direct.rs index 764f04f6..4b6d43c7 100644 --- a/crates/ruma-events/src/direct.rs +++ b/crates/ruma-events/src/direct.rs @@ -9,13 +9,12 @@ use ruma_events_macros::EventContent; use ruma_identifiers::{RoomId, UserId}; use serde::{Deserialize, Serialize}; -/// Informs the client about the rooms that are considered direct by a user. -pub type DirectEvent = crate::GlobalAccountDataEvent; - -/// The payload for `DirectEvent`. +/// The content of an `m.direct` event. /// -/// A mapping of `UserId`s to a list of `RoomId`s which are considered *direct* for that -/// particular user. +/// A mapping of `UserId`s to a list of `RoomId`s which are considered *direct* for that particular +/// user. +/// +/// Informs the client about the rooms that are considered direct by a user. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[allow(clippy::exhaustive_structs)] #[ruma_event(type = "m.direct", kind = GlobalAccountData)] diff --git a/crates/ruma-events/src/dummy.rs b/crates/ruma-events/src/dummy.rs index 1a468904..730c3f06 100644 --- a/crates/ruma-events/src/dummy.rs +++ b/crates/ruma-events/src/dummy.rs @@ -8,7 +8,7 @@ use serde::{ ser::{Serialize, SerializeStruct as _, Serializer}, }; -/// The payload for `DummyEvent`. +/// The content of an `m.dummy` event. /// /// This event is used to indicate new Olm sessions for end-to-end encryption. /// diff --git a/crates/ruma-events/src/forwarded_room_key.rs b/crates/ruma-events/src/forwarded_room_key.rs index 02c7c62a..a65aceb0 100644 --- a/crates/ruma-events/src/forwarded_room_key.rs +++ b/crates/ruma-events/src/forwarded_room_key.rs @@ -4,7 +4,7 @@ use ruma_events_macros::EventContent; use ruma_identifiers::{EventEncryptionAlgorithm, RoomId}; use serde::{Deserialize, Serialize}; -/// The payload for `ForwardedRoomKeyEvent`. +/// The content of an `m.forwarded_room_key` event. /// /// To create an instance of this type, first create a `ForwardedRoomKeyToDeviceEventContentInit` /// and convert it via `ForwardedRoomKeyToDeviceEventContent::from` / `.into()`. diff --git a/crates/ruma-events/src/fully_read.rs b/crates/ruma-events/src/fully_read.rs index f47855e7..68341f61 100644 --- a/crates/ruma-events/src/fully_read.rs +++ b/crates/ruma-events/src/fully_read.rs @@ -4,15 +4,11 @@ use ruma_events_macros::EventContent; use ruma_identifiers::EventId; use serde::{Deserialize, Serialize}; -use crate::RoomAccountDataEvent; - +/// The content of an `m.fully_read` event. +/// /// The current location of the user's read marker in a room. /// -/// This event appears in the user's room account data for the room the marker is applicable -/// for. -pub type FullyReadEvent = RoomAccountDataEvent; - -/// The payload for `FullyReadEvent`. +/// This event appears in the user's room account data for the room the marker is applicable for. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.fully_read", kind = RoomAccountData)] diff --git a/crates/ruma-events/src/ignored_user_list.rs b/crates/ruma-events/src/ignored_user_list.rs index 79564154..836760fe 100644 --- a/crates/ruma-events/src/ignored_user_list.rs +++ b/crates/ruma-events/src/ignored_user_list.rs @@ -4,12 +4,9 @@ use ruma_events_macros::EventContent; use ruma_identifiers::UserId; use serde::{Deserialize, Serialize}; -use crate::GlobalAccountDataEvent; - +/// The content of an `m.ignored_user_list` event. +/// /// A list of users to ignore. -pub type IgnoredUserListEvent = GlobalAccountDataEvent; - -/// The payload for `IgnoredUserListEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.ignored_user_list", kind = GlobalAccountData)] diff --git a/crates/ruma-events/src/key/verification/accept.rs b/crates/ruma-events/src/key/verification/accept.rs index 90c75f30..45e20e93 100644 --- a/crates/ruma-events/src/key/verification/accept.rs +++ b/crates/ruma-events/src/key/verification/accept.rs @@ -11,15 +11,10 @@ use super::Relation; use super::{ HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, ShortAuthenticationString, }; -#[cfg(feature = "unstable-pre-spec")] -use crate::MessageEvent; +/// The content of a to-device `m.key.verification.accept` event. +/// /// Accepts a previously sent *m.key.verification.start* message. -#[cfg(feature = "unstable-pre-spec")] -#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] -pub type AcceptEvent = MessageEvent; - -/// The payload for a to-device `AcceptEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.key.verification.accept", kind = ToDevice)] @@ -42,7 +37,9 @@ impl AcceptToDeviceEventContent { } } -/// The payload for a in-room `AcceptEvent`. +/// The content of a in-room `m.key.verification.accept` event. +/// +/// Accepts a previously sent *m.key.verification.start* message. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[ruma_event(type = "m.key.verification.accept", kind = Message)] #[cfg(feature = "unstable-pre-spec")] diff --git a/crates/ruma-events/src/key/verification/cancel.rs b/crates/ruma-events/src/key/verification/cancel.rs index 196cbb9a..7d367c81 100644 --- a/crates/ruma-events/src/key/verification/cancel.rs +++ b/crates/ruma-events/src/key/verification/cancel.rs @@ -6,15 +6,10 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "unstable-pre-spec")] use super::Relation; -#[cfg(feature = "unstable-pre-spec")] -use crate::MessageEvent; +/// The content of a to-device `m.key.verification.cancel` event. +/// /// Cancels a key verification process/request. -#[cfg(feature = "unstable-pre-spec")] -#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] -pub type CancelEvent = MessageEvent; - -/// The payload for a to-device `CancelEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.key.verification.cancel", kind = ToDevice)] @@ -38,7 +33,9 @@ impl CancelToDeviceEventContent { } } -/// The payload for an in-room `CancelEvent`. +/// The content of an in-room `m.key.verification.cancel` event. +/// +/// Cancels a key verification process/request. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg(feature = "unstable-pre-spec")] #[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] diff --git a/crates/ruma-events/src/key/verification/done.rs b/crates/ruma-events/src/key/verification/done.rs index 119ba7b2..0d141a2e 100644 --- a/crates/ruma-events/src/key/verification/done.rs +++ b/crates/ruma-events/src/key/verification/done.rs @@ -4,13 +4,10 @@ use ruma_events_macros::EventContent; use serde::{Deserialize, Serialize}; use super::Relation; -use crate::MessageEvent; -/// Event signaling that the interactive key verification has successfully -/// concluded. -pub type DoneEvent = MessageEvent; - -/// The payload for a to-device `m.key.verification.done` event. +/// The content of a to-device `m.m.key.verification.done` event. +/// +/// Event signaling that the interactive key verification has successfully concluded. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.key.verification.done", kind = ToDevice)] @@ -29,6 +26,8 @@ impl DoneToDeviceEventContent { } /// The payload for a in-room `m.key.verification.done` event. +/// +/// Event signaling that the interactive key verification has successfully concluded. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.key.verification.done", kind = Message)] diff --git a/crates/ruma-events/src/key/verification/key.rs b/crates/ruma-events/src/key/verification/key.rs index 58d25a62..2feac140 100644 --- a/crates/ruma-events/src/key/verification/key.rs +++ b/crates/ruma-events/src/key/verification/key.rs @@ -5,15 +5,10 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "unstable-pre-spec")] use super::Relation; -#[cfg(feature = "unstable-pre-spec")] -use crate::MessageEvent; +/// The content of a to-device `m.key.verification.key` event. +/// /// Sends the ephemeral public key for a device to the partner device. -#[cfg(feature = "unstable-pre-spec")] -#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] -pub type KeyEvent = MessageEvent; - -/// The payload for a to-device `KeyEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.key.verification.key", kind = ToDevice)] @@ -34,7 +29,9 @@ impl KeyToDeviceEventContent { } } -/// The payload for in-room `KeyEvent`. +/// The content of an in-room `m.key.verification.key` event. +/// +/// Sends the ephemeral public key for a device to the partner device. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg(feature = "unstable-pre-spec")] #[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] diff --git a/crates/ruma-events/src/key/verification/mac.rs b/crates/ruma-events/src/key/verification/mac.rs index dbcfa71d..8fe35ac9 100644 --- a/crates/ruma-events/src/key/verification/mac.rs +++ b/crates/ruma-events/src/key/verification/mac.rs @@ -7,15 +7,10 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "unstable-pre-spec")] use super::Relation; -#[cfg(feature = "unstable-pre-spec")] -use crate::MessageEvent; +/// The content of a to-device `m.key.verification.` event. +/// /// Sends the MAC of a device's key to the partner device. -#[cfg(feature = "unstable-pre-spec")] -#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] -pub type MacEvent = MessageEvent; - -/// The payload for a to-device `MacEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.key.verification.mac", kind = ToDevice)] @@ -43,7 +38,9 @@ impl MacToDeviceEventContent { } } -/// The payload for an in-room `MacEvent`. +/// The content of an in-room `m.key.verification.` event. +/// +/// Sends the MAC of a device's key to the partner device. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg(feature = "unstable-pre-spec")] #[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] diff --git a/crates/ruma-events/src/key/verification/ready.rs b/crates/ruma-events/src/key/verification/ready.rs index 54975716..b7afac0b 100644 --- a/crates/ruma-events/src/key/verification/ready.rs +++ b/crates/ruma-events/src/key/verification/ready.rs @@ -5,12 +5,10 @@ use ruma_identifiers::DeviceIdBox; use serde::{Deserialize, Serialize}; use super::{Relation, VerificationMethod}; -use crate::MessageEvent; +/// The content of a to-device `m.m.key.verification.ready` event. +/// /// Response to a previously sent *m.key.verification.request* message. -pub type ReadyEvent = MessageEvent; - -/// The payload for a to-device `m.key.verification.ready` event. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.key.verification.ready", kind = ToDevice)] @@ -41,7 +39,9 @@ impl ReadyToDeviceEventContent { } } -/// The payload for an in-room `m.key.verification.ready` event. +/// The content of an in-room `m.m.key.verification.ready` event. +/// +/// Response to a previously sent *m.key.verification.request* message. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.key.verification.ready", kind = Message)] diff --git a/crates/ruma-events/src/key/verification/request.rs b/crates/ruma-events/src/key/verification/request.rs index a33b23db..868c221b 100644 --- a/crates/ruma-events/src/key/verification/request.rs +++ b/crates/ruma-events/src/key/verification/request.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; use super::VerificationMethod; -/// The payload for `RequestEvent`. +/// The content of an `m.key.verification.request` event. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.key.verification.request", kind = ToDevice)] diff --git a/crates/ruma-events/src/key/verification/start.rs b/crates/ruma-events/src/key/verification/start.rs index d710a04d..78ebdee8 100644 --- a/crates/ruma-events/src/key/verification/start.rs +++ b/crates/ruma-events/src/key/verification/start.rs @@ -12,15 +12,10 @@ use super::Relation; use super::{ HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, ShortAuthenticationString, }; -#[cfg(feature = "unstable-pre-spec")] -use crate::MessageEvent; +/// The content of a to-device `m.key.verification.start` event. +/// /// Begins an SAS key verification process. -#[cfg(feature = "unstable-pre-spec")] -#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] -pub type StartEvent = MessageEvent; - -/// The payload of a to-device *m.key.verification.start* event. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.key.verification.start", kind = ToDevice)] @@ -48,7 +43,9 @@ impl StartToDeviceEventContent { } } -/// The payload of an in-room *m.key.verification.start* event. +/// The content of an in-room `m.key.verification.start` event. +/// +/// Begins an SAS key verification process. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg(feature = "unstable-pre-spec")] #[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] diff --git a/crates/ruma-events/src/policy/rule/room.rs b/crates/ruma-events/src/policy/rule/room.rs index 2a3b5b90..8ccbc9e0 100644 --- a/crates/ruma-events/src/policy/rule/room.rs +++ b/crates/ruma-events/src/policy/rule/room.rs @@ -3,12 +3,11 @@ use ruma_events_macros::EventContent; use serde::{Deserialize, Serialize}; -use crate::{policy::rule::PolicyRuleEventContent, StateEvent}; +use crate::policy::rule::PolicyRuleEventContent; +/// The content of an `m.policy.rule.room` event. +/// /// This event type is used to apply rules to room entities. -pub type RoomEvent = StateEvent; - -/// The payload for `RoomEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[allow(clippy::exhaustive_structs)] #[ruma_event(type = "m.policy.rule.room", kind = State)] diff --git a/crates/ruma-events/src/policy/rule/server.rs b/crates/ruma-events/src/policy/rule/server.rs index d771410c..3524c6ea 100644 --- a/crates/ruma-events/src/policy/rule/server.rs +++ b/crates/ruma-events/src/policy/rule/server.rs @@ -3,12 +3,11 @@ use ruma_events_macros::EventContent; use serde::{Deserialize, Serialize}; -use crate::{policy::rule::PolicyRuleEventContent, StateEvent}; +use crate::policy::rule::PolicyRuleEventContent; +/// The content of an `m.policy.rule.server` event. +/// /// This event type is used to apply rules to server entities. -pub type ServerEvent = StateEvent; - -/// The payload for `ServerEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[allow(clippy::exhaustive_structs)] #[ruma_event(type = "m.policy.rule.server", kind = State)] diff --git a/crates/ruma-events/src/policy/rule/user.rs b/crates/ruma-events/src/policy/rule/user.rs index 4367582d..3eca0db5 100644 --- a/crates/ruma-events/src/policy/rule/user.rs +++ b/crates/ruma-events/src/policy/rule/user.rs @@ -3,12 +3,11 @@ use ruma_events_macros::EventContent; use serde::{Deserialize, Serialize}; -use crate::{policy::rule::PolicyRuleEventContent, StateEvent}; +use crate::policy::rule::PolicyRuleEventContent; +/// The content of an `m.policy.rule.user` event. +/// /// This event type is used to apply rules to user entities. -pub type UserEvent = StateEvent; - -/// The payload for `UserEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[allow(clippy::exhaustive_structs)] #[ruma_event(type = "m.policy.rule.user", kind = State)] diff --git a/crates/ruma-events/src/push_rules.rs b/crates/ruma-events/src/push_rules.rs index ffdd0d32..f4e4d9ed 100644 --- a/crates/ruma-events/src/push_rules.rs +++ b/crates/ruma-events/src/push_rules.rs @@ -4,12 +4,9 @@ use ruma_common::push::Ruleset; use ruma_events_macros::EventContent; use serde::{Deserialize, Serialize}; -use crate::GlobalAccountDataEvent; - +/// The content of an `m.push_rules` event. +/// /// Describes all push rules for a user. -pub type PushRulesEvent = GlobalAccountDataEvent; - -/// The payload for `PushRulesEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.push_rules", kind = GlobalAccountData)] diff --git a/crates/ruma-events/src/reaction.rs b/crates/ruma-events/src/reaction.rs index 66b2d570..a313b7f9 100644 --- a/crates/ruma-events/src/reaction.rs +++ b/crates/ruma-events/src/reaction.rs @@ -4,12 +4,9 @@ use ruma_events_macros::EventContent; use ruma_identifiers::EventId; use serde::{Deserialize, Serialize}; -use crate::MessageEvent; - +/// The payload for a `m.reaction` event. +/// /// A reaction to another event. -pub type ReactionEvent = MessageEvent; - -/// The payload for a `ReactionEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.reaction", kind = Message)] diff --git a/crates/ruma-events/src/receipt.rs b/crates/ruma-events/src/receipt.rs index 10c30ec7..a4f0362b 100644 --- a/crates/ruma-events/src/receipt.rs +++ b/crates/ruma-events/src/receipt.rs @@ -10,15 +10,12 @@ use ruma_events_macros::EventContent; use ruma_identifiers::{EventId, UserId}; use serde::{Deserialize, Serialize}; -use crate::EphemeralRoomEvent; - -/// Informs the client who has read a message specified by it's event id. -pub type ReceiptEvent = EphemeralRoomEvent; - -/// The payload for `ReceiptEvent`. +/// The content of an `m.receipt` event. /// /// A mapping of event ID to a collection of receipts for this event ID. The event ID is the ID of /// the event being acknowledged and *not* an ID for the receipt itself. +/// +/// Informs the client who has read a message specified by it's event id. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[allow(clippy::exhaustive_structs)] #[ruma_event(type = "m.receipt", kind = EphemeralRoom)] diff --git a/crates/ruma-events/src/room/aliases.rs b/crates/ruma-events/src/room/aliases.rs index d86df4a2..4e5590cb 100644 --- a/crates/ruma-events/src/room/aliases.rs +++ b/crates/ruma-events/src/room/aliases.rs @@ -7,13 +7,12 @@ use serde_json::value::RawValue as RawJsonValue; use crate::{ EventContent, HasDeserializeFields, RedactContent, RedactedEventContent, - RedactedStateEventContent, StateEvent, + RedactedStateEventContent, }; +/// The content of an `m.room.aliases` event. +/// /// Informs the room about what room aliases it has been given. -pub type AliasesEvent = StateEvent; - -/// The payload for `AliasesEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.aliases", kind = State, custom_redacted)] diff --git a/crates/ruma-events/src/room/avatar.rs b/crates/ruma-events/src/room/avatar.rs index ab20163a..6a657d1b 100644 --- a/crates/ruma-events/src/room/avatar.rs +++ b/crates/ruma-events/src/room/avatar.rs @@ -6,14 +6,12 @@ use ruma_identifiers::MxcUri; use serde::{Deserialize, Serialize}; use super::ThumbnailInfo; -use crate::StateEvent; +/// The content of an `m.room.avatar` event. +/// /// A picture that is associated with the room. /// /// This can be displayed alongside the room information. -pub type AvatarEvent = StateEvent; - -/// The payload for `AvatarEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(feature = "unstable-pre-spec", derive(Default))] diff --git a/crates/ruma-events/src/room/canonical_alias.rs b/crates/ruma-events/src/room/canonical_alias.rs index af14da94..7231e8f2 100644 --- a/crates/ruma-events/src/room/canonical_alias.rs +++ b/crates/ruma-events/src/room/canonical_alias.rs @@ -4,12 +4,9 @@ use ruma_events_macros::EventContent; use ruma_identifiers::RoomAliasId; use serde::{Deserialize, Serialize}; -use crate::StateEvent; - +/// The content of an `m.room.canonical_alias` event. +/// /// Informs the room as to which alias is the canonical one. -pub type CanonicalAliasEvent = StateEvent; - -/// The payload for `CanonicalAliasEvent`. #[derive(Clone, Debug, Default, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.canonical_alias", kind = State)] diff --git a/crates/ruma-events/src/room/create.rs b/crates/ruma-events/src/room/create.rs index 67c2dce7..e5932b3d 100644 --- a/crates/ruma-events/src/room/create.rs +++ b/crates/ruma-events/src/room/create.rs @@ -5,14 +5,11 @@ use ruma_identifiers::{EventId, RoomId, RoomVersionId, UserId}; use ruma_serde::StringEnum; use serde::{Deserialize, Serialize}; -use crate::StateEvent; - +/// The content of an `m.room.create` event. +/// /// This is the first event in a room and cannot be changed. /// /// It acts as the root of all other events. -pub type CreateEvent = StateEvent; - -/// The payload for `CreateEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.create", kind = State)] diff --git a/crates/ruma-events/src/room/encrypted.rs b/crates/ruma-events/src/room/encrypted.rs index cf486325..adcef4c7 100644 --- a/crates/ruma-events/src/room/encrypted.rs +++ b/crates/ruma-events/src/room/encrypted.rs @@ -9,19 +9,13 @@ use ruma_identifiers::DeviceIdBox; use ruma_identifiers::EventId; use serde::{Deserialize, Serialize}; +use crate::room::message::{self, InReplyTo}; #[cfg(feature = "unstable-pre-spec")] use crate::{key::verification, reaction}; -use crate::{ - room::message::{self, InReplyTo}, - MessageEvent, -}; mod relation_serde; -/// An event that has been encrypted. -pub type EncryptedEvent = MessageEvent; - -/// The content payload for `EncryptedEvent`. +/// The content of an `m.room.encrypted` event. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.encrypted", kind = Message, kind = ToDevice)] @@ -50,7 +44,7 @@ impl From for EncryptedEventContent { } } -/// The to-device content payload for `m.encrypted` events. +/// The to-device content of an `m.room.encrypted` event. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.encrypted", kind = ToDevice)] @@ -122,7 +116,7 @@ pub enum Relation { /// The event this relation belongs to replaces another event. /// /// In contrast to [`message::Replacement`], this struct doesn't store the new content, since that -/// is part of the encrypted payload for `m.encrypted` events. +/// is part of the encrypted content of an `m.room.encrypted` events. #[derive(Clone, Debug, Deserialize, Serialize)] #[cfg(feature = "unstable-pre-spec")] #[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] @@ -171,7 +165,7 @@ impl Annotation { } } -/// The payload for `EncryptedEvent` using the *m.olm.v1.curve25519-aes-sha2* algorithm. +/// The content of an `m.room.encrypted` event using the *m.olm.v1.curve25519-aes-sha2* algorithm. #[derive(Clone, Debug, Serialize, Deserialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct OlmV1Curve25519AesSha2Content { @@ -210,7 +204,7 @@ impl CiphertextInfo { } } -/// The payload for `EncryptedEvent` using the *m.megolm.v1.aes-sha2* algorithm. +/// The content of an `m.room.encrypted` event using the *m.megolm.v1.aes-sha2* algorithm. /// /// To create an instance of this type, first create a `MegolmV1AesSha2ContentInit` and convert it /// via `MegolmV1AesSha2Content::from` / `.into()`. diff --git a/crates/ruma-events/src/room/encryption.rs b/crates/ruma-events/src/room/encryption.rs index f88a85e5..02a4729a 100644 --- a/crates/ruma-events/src/room/encryption.rs +++ b/crates/ruma-events/src/room/encryption.rs @@ -4,12 +4,11 @@ use js_int::UInt; use ruma_events_macros::EventContent; use serde::{Deserialize, Serialize}; -use crate::{EventEncryptionAlgorithm, StateEvent}; +use crate::EventEncryptionAlgorithm; +/// The content of an `m.room.encryption` event. +/// /// Defines how messages sent in this room should be encrypted. -pub type EncryptionEvent = StateEvent; - -/// The payload for `EncryptionEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.encryption", kind = State)] diff --git a/crates/ruma-events/src/room/guest_access.rs b/crates/ruma-events/src/room/guest_access.rs index 26e51d2f..d9cea55e 100644 --- a/crates/ruma-events/src/room/guest_access.rs +++ b/crates/ruma-events/src/room/guest_access.rs @@ -4,15 +4,12 @@ use ruma_events_macros::EventContent; use ruma_serde::StringEnum; use serde::{Deserialize, Serialize}; -use crate::StateEvent; - +/// The content of an `m.room.guest_access` event. +/// /// Controls whether guest users are allowed to join rooms. /// /// This event controls whether guest users are allowed to join rooms. If this event is absent, /// servers should act as if it is present and has the value `GuestAccess::Forbidden`. -pub type GuestAccessEvent = StateEvent; - -/// The payload for `GuestAccessEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.guest_access", kind = State)] diff --git a/crates/ruma-events/src/room/history_visibility.rs b/crates/ruma-events/src/room/history_visibility.rs index 84622e82..ee8db194 100644 --- a/crates/ruma-events/src/room/history_visibility.rs +++ b/crates/ruma-events/src/room/history_visibility.rs @@ -4,13 +4,10 @@ use ruma_events_macros::EventContent; use ruma_serde::StringEnum; use serde::{Deserialize, Serialize}; -use crate::StateEvent; - +/// The content of an `m.room.history_visibility` event. +/// /// This event controls whether a member of a room can see the events that happened in a room /// from before they joined. -pub type HistoryVisibilityEvent = StateEvent; - -/// The payload for `HistoryVisibilityEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.history_visibility", kind = State)] diff --git a/crates/ruma-events/src/room/join_rules.rs b/crates/ruma-events/src/room/join_rules.rs index e2b45b5f..d576ec02 100644 --- a/crates/ruma-events/src/room/join_rules.rs +++ b/crates/ruma-events/src/room/join_rules.rs @@ -16,12 +16,9 @@ use std::borrow::Cow; #[cfg(feature = "unstable-pre-spec")] use std::collections::BTreeMap; -use crate::StateEvent; - +/// The content of an `m.room.join_rules` event. +/// /// Describes how users are allowed to join the room. -pub type JoinRulesEvent = StateEvent; - -/// The payload for `JoinRulesEvent`. #[derive(Clone, Debug, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.join_rules", kind = State)] diff --git a/crates/ruma-events/src/room/member.rs b/crates/ruma-events/src/room/member.rs index a01204cc..856348f9 100644 --- a/crates/ruma-events/src/room/member.rs +++ b/crates/ruma-events/src/room/member.rs @@ -7,8 +7,10 @@ use ruma_identifiers::{MxcUri, ServerNameBox, ServerSigningKeyId, UserId}; use ruma_serde::StringEnum; use serde::{Deserialize, Serialize}; -use crate::{StateEvent, StrippedStateEvent, SyncStateEvent}; +use crate::{StrippedStateEvent, SyncStateEvent}; +/// The content of an `m.room.member` event. +/// /// The current membership state of a user in the room. /// /// Adjusts the membership state for a user in a room. It is preferable to use the membership @@ -34,9 +36,6 @@ use crate::{StateEvent, StrippedStateEvent, SyncStateEvent}; /// The membership for a given user can change over time. Previous membership can be retrieved /// from the `prev_content` object on an event. If not present, the user's previous membership /// must be assumed as leave. -pub type MemberEvent = StateEvent; - -/// The payload for `MemberEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.member", kind = State)] diff --git a/crates/ruma-events/src/room/message.rs b/crates/ruma-events/src/room/message.rs index 8cefa2ff..1359d09f 100644 --- a/crates/ruma-events/src/room/message.rs +++ b/crates/ruma-events/src/room/message.rs @@ -20,12 +20,11 @@ mod content_serde; pub mod feedback; mod relation_serde; +/// The content of an `m.room.message` event. +/// /// This event is used when sending messages in a room. /// /// Messages are not limited to be text. -pub type MessageEvent = crate::MessageEvent; - -/// The payload for `MessageEvent`. #[derive(Clone, Debug, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.message", kind = Message)] diff --git a/crates/ruma-events/src/room/message/feedback.rs b/crates/ruma-events/src/room/message/feedback.rs index db475d09..c1b526e5 100644 --- a/crates/ruma-events/src/room/message/feedback.rs +++ b/crates/ruma-events/src/room/message/feedback.rs @@ -5,15 +5,12 @@ use ruma_identifiers::EventId; use ruma_serde::StringEnum; use serde::{Deserialize, Serialize}; -use crate::MessageEvent; - +/// The content of an `m.room.message.feedback` event. +/// /// An acknowledgement of a message. /// /// N.B.: Usage of this event is discouraged in favor of the receipts module. Most clients will /// not recognize this event. -pub type FeedbackEvent = MessageEvent; - -/// The payload for `FeedbackEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.message.feedback", kind = Message)] diff --git a/crates/ruma-events/src/room/name.rs b/crates/ruma-events/src/room/name.rs index b9527d63..e44c583e 100644 --- a/crates/ruma-events/src/room/name.rs +++ b/crates/ruma-events/src/room/name.rs @@ -4,12 +4,9 @@ use ruma_events_macros::EventContent; use ruma_identifiers::RoomNameBox; use serde::{Deserialize, Serialize}; -use crate::StateEvent; - +/// The content of an `m.room.name` event. +/// /// The room name is a human-friendly string designed to be displayed to the end-user. -pub type NameEvent = StateEvent; - -/// The payload for `NameEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[ruma_event(type = "m.room.name", kind = State)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] diff --git a/crates/ruma-events/src/room/pinned_events.rs b/crates/ruma-events/src/room/pinned_events.rs index 3ea6229f..cefd8aaa 100644 --- a/crates/ruma-events/src/room/pinned_events.rs +++ b/crates/ruma-events/src/room/pinned_events.rs @@ -4,12 +4,9 @@ use ruma_events_macros::EventContent; use ruma_identifiers::EventId; use serde::{Deserialize, Serialize}; -use crate::StateEvent; - +/// The content of an `m.room.pinned_events` event. +/// /// Used to "pin" particular events in a room for other participants to review later. -pub type PinnedEventsEvent = StateEvent; - -/// The payload for `PinnedEventsEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.pinned_events", kind = State)] diff --git a/crates/ruma-events/src/room/power_levels.rs b/crates/ruma-events/src/room/power_levels.rs index 69f03ccd..3ee64745 100644 --- a/crates/ruma-events/src/room/power_levels.rs +++ b/crates/ruma-events/src/room/power_levels.rs @@ -8,14 +8,13 @@ use ruma_events_macros::EventContent; use ruma_identifiers::UserId; use serde::{Deserialize, Serialize}; -use crate::{EventType, StateEvent}; +use crate::EventType; use ruma_common::power_levels::NotificationPowerLevels; +/// The content of an `m.room.power_levels` event. +/// /// Defines the power levels (privileges) of users in the room. -pub type PowerLevelsEvent = StateEvent; - -/// The payload for `PowerLevelsEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.power_levels", kind = State)] diff --git a/crates/ruma-events/src/room/server_acl.rs b/crates/ruma-events/src/room/server_acl.rs index 1ce5ab05..c1b2dec6 100644 --- a/crates/ruma-events/src/room/server_acl.rs +++ b/crates/ruma-events/src/room/server_acl.rs @@ -3,12 +3,9 @@ use ruma_events_macros::EventContent; use serde::{Deserialize, Serialize}; -use crate::StateEvent; - +/// The content of an `m.room.server_acl` event. +/// /// An event to indicate which servers are permitted to participate in the room. -pub type ServerAclEvent = StateEvent; - -/// The payload for `ServerAclEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.server_acl", kind = State)] diff --git a/crates/ruma-events/src/room/third_party_invite.rs b/crates/ruma-events/src/room/third_party_invite.rs index 07e01a18..bc62ad14 100644 --- a/crates/ruma-events/src/room/third_party_invite.rs +++ b/crates/ruma-events/src/room/third_party_invite.rs @@ -3,16 +3,13 @@ use ruma_events_macros::EventContent; use serde::{Deserialize, Serialize}; -use crate::StateEvent; - +/// The content of an `m.room.third_party_invite` event. +/// /// An invitation to a room issued to a third party identifier, rather than a matrix user ID. /// /// Acts as an *m.room.member* invite event, where there isn't a target user_id to invite. This /// event contains a token and a public key whose private key must be used to sign the token. /// Any user who can present that signature may use this invitation to join the target room. -pub type ThirdPartyInviteEvent = StateEvent; - -/// The payload for `ThirdPartyInviteEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.third_party_invite", kind = State)] diff --git a/crates/ruma-events/src/room/tombstone.rs b/crates/ruma-events/src/room/tombstone.rs index 7818baa2..54a5dd55 100644 --- a/crates/ruma-events/src/room/tombstone.rs +++ b/crates/ruma-events/src/room/tombstone.rs @@ -4,13 +4,10 @@ use ruma_events_macros::EventContent; use ruma_identifiers::RoomId; use serde::{Deserialize, Serialize}; -use crate::StateEvent; - +/// The content of an `m.room.tombstone` event. +/// /// A state event signifying that a room has been upgraded to a different room version, and that /// clients should go there. -pub type TombstoneEvent = StateEvent; - -/// The payload for `TombstoneEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[ruma_event(type = "m.room.tombstone", kind = State)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] diff --git a/crates/ruma-events/src/room/topic.rs b/crates/ruma-events/src/room/topic.rs index 9acbff66..e7a6e5a2 100644 --- a/crates/ruma-events/src/room/topic.rs +++ b/crates/ruma-events/src/room/topic.rs @@ -3,12 +3,9 @@ use ruma_events_macros::EventContent; use serde::{Deserialize, Serialize}; -use crate::StateEvent; - +/// The content of an `m.room.topic` event. +/// /// A topic is a short message detailing what is currently being discussed in the room. -pub type TopicEvent = StateEvent; - -/// The payload for `TopicEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room.topic", kind = State)] diff --git a/crates/ruma-events/src/room_key.rs b/crates/ruma-events/src/room_key.rs index f07c2226..acc3018d 100644 --- a/crates/ruma-events/src/room_key.rs +++ b/crates/ruma-events/src/room_key.rs @@ -4,7 +4,7 @@ use ruma_events_macros::EventContent; use ruma_identifiers::{EventEncryptionAlgorithm, RoomId}; use serde::{Deserialize, Serialize}; -/// The payload for `RoomKeyEvent`. +/// The content of an `m.room_key` event. /// /// Typically encrypted as an *m.room.encrypted* event, then sent as a to-device event. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] diff --git a/crates/ruma-events/src/room_key_request.rs b/crates/ruma-events/src/room_key_request.rs index c44c19d2..9d5a1164 100644 --- a/crates/ruma-events/src/room_key_request.rs +++ b/crates/ruma-events/src/room_key_request.rs @@ -5,7 +5,7 @@ use ruma_identifiers::{DeviceIdBox, EventEncryptionAlgorithm, RoomId}; use ruma_serde::StringEnum; use serde::{Deserialize, Serialize}; -/// The payload for `RoomKeyRequestEvent`. +/// The content of an `m.room_key_request` event. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.room_key_request", kind = ToDevice)] diff --git a/crates/ruma-events/src/secret/request.rs b/crates/ruma-events/src/secret/request.rs index f7f5ece6..2d79f263 100644 --- a/crates/ruma-events/src/secret/request.rs +++ b/crates/ruma-events/src/secret/request.rs @@ -7,14 +7,11 @@ use ruma_identifiers::DeviceIdBox; use ruma_serde::StringEnum; use serde::{ser::SerializeStruct, Deserialize, Serialize}; -use crate::ToDeviceEvent; - +/// The content of an `m.secret.request` event. +/// /// Event sent by a client to request a secret from another device or to cancel a previous request. /// /// It is sent as an unencrypted to-device event. -pub type RequestToDeviceEvent = ToDeviceEvent; - -/// The payload for RequestToDeviceEvent. #[derive(Clone, Debug, Serialize, Deserialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.secret.request", kind = ToDevice)] diff --git a/crates/ruma-events/src/secret/send.rs b/crates/ruma-events/src/secret/send.rs index 41361425..370968b6 100644 --- a/crates/ruma-events/src/secret/send.rs +++ b/crates/ruma-events/src/secret/send.rs @@ -3,15 +3,12 @@ use ruma_events_macros::EventContent; use serde::{Deserialize, Serialize}; -use crate::ToDeviceEvent; - +/// The content of an `m.secret.send` event. +/// /// An event sent by a client to share a secret with another device, in response to an /// `m.secret.request` event. /// /// It must be encrypted as an `m.room.encrypted` event, then sent as a to-device event. -pub type SendToDeviceEvent = ToDeviceEvent; - -/// The payload for `SendToDeviceEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.secret.send", kind = ToDevice)] diff --git a/crates/ruma-events/src/space/child.rs b/crates/ruma-events/src/space/child.rs index 3d29b7ff..7276d637 100644 --- a/crates/ruma-events/src/space/child.rs +++ b/crates/ruma-events/src/space/child.rs @@ -4,16 +4,13 @@ use ruma_events_macros::EventContent; use ruma_identifiers::ServerNameBox; use serde::{Deserialize, Serialize}; -use crate::StateEvent; - +/// The content of an `m.space.child` event. +/// /// The admins of a space can advertise rooms and subspaces for their space by setting /// `m.space.child` state events. /// /// The `state_key` is the ID of a child room or space, and the content must contain a `via` key /// which gives a list of candidate servers that can be used to join the room. -pub type ChildEvent = StateEvent; - -/// The payload for `ChildEvent`. #[derive(Clone, Debug, Default, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.space.child", kind = State)] diff --git a/crates/ruma-events/src/space/parent.rs b/crates/ruma-events/src/space/parent.rs index 8b94bf8d..213e1b8a 100644 --- a/crates/ruma-events/src/space/parent.rs +++ b/crates/ruma-events/src/space/parent.rs @@ -4,16 +4,13 @@ use ruma_events_macros::EventContent; use ruma_identifiers::ServerNameBox; use serde::{Deserialize, Serialize}; -use crate::StateEvent; - +/// The content of an `m.space.parent` event. +/// /// Rooms can claim parents via the `m.space.parent` state event. /// /// Similar to `m.space.child`, the `state_key` is the ID of the parent space, and the content must /// contain a `via` key which gives a list of candidate servers that can be used to join the /// parent. -pub type ParentEvent = StateEvent; - -/// The payload for `ParentEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.space.parent", kind = State)] diff --git a/crates/ruma-events/src/sticker.rs b/crates/ruma-events/src/sticker.rs index 4023ce54..4b2cd9db 100644 --- a/crates/ruma-events/src/sticker.rs +++ b/crates/ruma-events/src/sticker.rs @@ -4,12 +4,11 @@ use ruma_events_macros::EventContent; use ruma_identifiers::MxcUri; use serde::{Deserialize, Serialize}; -use crate::{room::ImageInfo, MessageEvent}; +use crate::room::ImageInfo; +/// The content of an `m.sticker` event. +/// /// A sticker message. -pub type StickerEvent = MessageEvent; - -/// The payload for `StickerEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.sticker", kind = Message)] diff --git a/crates/ruma-events/src/tag.rs b/crates/ruma-events/src/tag.rs index d5830000..0cec4556 100644 --- a/crates/ruma-events/src/tag.rs +++ b/crates/ruma-events/src/tag.rs @@ -6,15 +6,12 @@ use ruma_events_macros::EventContent; use ruma_serde::deserialize_cow_str; use serde::{Deserialize, Serialize}; -use crate::RoomAccountDataEvent; - -/// Informs the client of tags on a room. -pub type TagEvent = RoomAccountDataEvent; - /// Map of tag names to tag info. pub type Tags = BTreeMap; -/// The payload for `TagEvent`. +/// The content of an `m.tag` event. +/// +/// Informs the client of tags on a room. #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.tag", kind = RoomAccountData)] diff --git a/crates/ruma-events/src/typing.rs b/crates/ruma-events/src/typing.rs index b9c84716..a726cbdc 100644 --- a/crates/ruma-events/src/typing.rs +++ b/crates/ruma-events/src/typing.rs @@ -4,12 +4,9 @@ use ruma_events_macros::EventContent; use ruma_identifiers::UserId; use serde::{Deserialize, Serialize}; -use crate::EphemeralRoomEvent; - +/// The content of an `m.typing` event. +/// /// Informs the client who is currently typing in a given room. -pub type TypingEvent = EphemeralRoomEvent; - -/// The payload for `TypingEvent`. #[derive(Clone, Debug, Default, Deserialize, Serialize, EventContent)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[ruma_event(type = "m.typing", kind = EphemeralRoom)] diff --git a/crates/ruma-events/tests/ui/01-content-sanity-check.rs b/crates/ruma-events/tests/ui/01-content-sanity-check.rs index 9b504866..b129ae65 100644 --- a/crates/ruma-events/tests/ui/01-content-sanity-check.rs +++ b/crates/ruma-events/tests/ui/01-content-sanity-check.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[ruma_event(type = "m.macro.test", kind = State)] -pub struct MacroTest { +pub struct MacroTestContent { pub url: String, }