macros: Rename ruma-events-macros to ruma-macros

This commit is contained in:
Kévin Commaille 2022-02-27 13:54:17 +01:00 committed by GitHub
parent 60b2212a57
commit f2dca60fc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
78 changed files with 97 additions and 117 deletions

View File

@ -1,23 +0,0 @@
Since version 0.19.0 of ruma-events, ruma-events-macros is versioned in lockstep with ruma-api.
Since ruma-events-macros cannot be used independently anyway, it no longer maintains a separate
change log or its own version. Instead, refer to ruma-events's change log for changes in versions
0.19.0 and above.
# 0.3.0
Breaking changes:
* Update `event_type` in `ruma_events!` to refer to the serialized form of the
event type, not the variant of `ruma_events::EventType`
Improvements:
* Split `FromRaw` implementation generation from `ruma_event!` into a separate
proc-macro
# 0.2.0
Improvements:
* Code generation was updated to account for the changes in ruma-events 0.15
* Dependencies were updated (notably to syn 1.0 and quote 1.0)

View File

@ -1,5 +0,0 @@
# ruma-events-macros
**ruma-events-macros** provides a procedural macro for easily generating event types for [ruma-events].
[ruma-events]: https://github.com/ruma/ruma/tree/main/ruma-events

View File

@ -15,7 +15,7 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"]
[features] [features]
compat = ["ruma-events-macros/compat"] compat = ["ruma-macros/compat"]
markdown = ["pulldown-cmark"] markdown = ["pulldown-cmark"]
unstable-exhaustive-types = [] unstable-exhaustive-types = []
@ -32,8 +32,8 @@ indoc = "1.0"
js_int = { version = "0.2.0", features = ["serde"] } js_int = { version = "0.2.0", features = ["serde"] }
pulldown-cmark = { version = "0.8", default-features = false, optional = true } pulldown-cmark = { version = "0.8", default-features = false, optional = true }
ruma-common = { version = "0.8.0", path = "../ruma-common" } ruma-common = { version = "0.8.0", path = "../ruma-common" }
ruma-events-macros = { version = "=0.26.0", path = "../ruma-events-macros" }
ruma-identifiers = { version = "0.22.0", path = "../ruma-identifiers", features = ["serde"] } ruma-identifiers = { version = "0.22.0", path = "../ruma-identifiers", features = ["serde"] }
ruma-macros = { version = "=0.1.0", path = "../ruma-macros" }
ruma-serde = { version = "0.6.0", path = "../ruma-serde" } ruma-serde = { version = "0.6.0", path = "../ruma-serde" }
serde = { version = "1.0.118", features = ["derive"] } serde = { version = "1.0.118", features = ["derive"] }
serde_json = { version = "1.0.60", features = ["raw_value"] } serde_json = { version = "1.0.60", features = ["raw_value"] }

View File

@ -3,7 +3,7 @@
//! [`m.call.answer`]: https://spec.matrix.org/v1.2/client-server-api/#mcallanswer //! [`m.call.answer`]: https://spec.matrix.org/v1.2/client-server-api/#mcallanswer
use js_int::UInt; use js_int::UInt;
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::SessionDescription; use super::SessionDescription;

View File

@ -3,7 +3,7 @@
//! [`m.call.candidates`]: https://spec.matrix.org/v1.2/client-server-api/#mcallcandidates //! [`m.call.candidates`]: https://spec.matrix.org/v1.2/client-server-api/#mcallcandidates
use js_int::UInt; use js_int::UInt;
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.call.candidates` event. /// The content of an `m.call.candidates` event.

View File

@ -3,7 +3,7 @@
//! [`m.call.hangup`]: https://spec.matrix.org/v1.2/client-server-api/#mcallhangup //! [`m.call.hangup`]: https://spec.matrix.org/v1.2/client-server-api/#mcallhangup
use js_int::UInt; use js_int::UInt;
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use ruma_serde::StringEnum; use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -3,7 +3,7 @@
//! [`m.call.invite`]: https://spec.matrix.org/v1.2/client-server-api/#mcallinvite //! [`m.call.invite`]: https://spec.matrix.org/v1.2/client-server-api/#mcallinvite
use js_int::UInt; use js_int::UInt;
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::SessionDescription; use super::SessionDescription;

View File

@ -7,8 +7,8 @@ use std::{
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
}; };
use ruma_events_macros::EventContent;
use ruma_identifiers::{RoomId, UserId}; use ruma_identifiers::{RoomId, UserId};
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.direct` event. /// The content of an `m.direct` event.

View File

@ -4,7 +4,7 @@
use std::fmt; use std::fmt;
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use serde::{ use serde::{
de::{self, Deserialize, Deserializer}, de::{self, Deserialize, Deserializer},
ser::{Serialize, SerializeStruct as _, Serializer}, ser::{Serialize, SerializeStruct as _, Serializer},

View File

@ -1,6 +1,6 @@
use ruma_common::MilliSecondsSinceUnixEpoch; use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events_macros::{event_enum, EventEnumFromEvent};
use ruma_identifiers::{EventId, RoomId, RoomVersionId, UserId}; use ruma_identifiers::{EventId, RoomId, RoomVersionId, UserId};
use ruma_macros::{event_enum, EventEnumFromEvent};
use ruma_serde::from_raw_json_value; use ruma_serde::from_raw_json_value;
use serde::{de, Deserialize}; use serde::{de, Deserialize};
use serde_json::value::RawValue as RawJsonValue; use serde_json::value::RawValue as RawJsonValue;

View File

@ -1,8 +1,8 @@
#![allow(clippy::exhaustive_structs)] #![allow(clippy::exhaustive_structs)]
use ruma_common::MilliSecondsSinceUnixEpoch; use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events_macros::Event;
use ruma_identifiers::{EventId, RoomId, UserId}; use ruma_identifiers::{EventId, RoomId, UserId};
use ruma_macros::Event;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.forwarded_room_key`]: https://spec.matrix.org/v1.2/client-server-api/#mforwarded_room_key //! [`m.forwarded_room_key`]: https://spec.matrix.org/v1.2/client-server-api/#mforwarded_room_key
use ruma_events_macros::EventContent;
use ruma_identifiers::{EventEncryptionAlgorithm, RoomId}; use ruma_identifiers::{EventEncryptionAlgorithm, RoomId};
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.forwarded_room_key` event. /// The content of an `m.forwarded_room_key` event.

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.fully_read`]: https://spec.matrix.org/v1.2/client-server-api/#mfully_read //! [`m.fully_read`]: https://spec.matrix.org/v1.2/client-server-api/#mfully_read
use ruma_events_macros::EventContent;
use ruma_identifiers::EventId; use ruma_identifiers::EventId;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.fully_read` event. /// The content of an `m.fully_read` event.

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.ignored_user_list`]: https://spec.matrix.org/v1.2/client-server-api/#mignored_user_list //! [`m.ignored_user_list`]: https://spec.matrix.org/v1.2/client-server-api/#mignored_user_list
use ruma_events_macros::EventContent;
use ruma_identifiers::UserId; use ruma_identifiers::UserId;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.ignored_user_list` event. /// The content of an `m.ignored_user_list` event.

View File

@ -4,8 +4,8 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_events_macros::EventContent;
use ruma_identifiers::TransactionId; use ruma_identifiers::TransactionId;
use ruma_macros::EventContent;
use ruma_serde::Base64; use ruma_serde::Base64;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.key.verification.cancel`]: https://spec.matrix.org/v1.2/client-server-api/#mkeyverificationcancel //! [`m.key.verification.cancel`]: https://spec.matrix.org/v1.2/client-server-api/#mkeyverificationcancel
use ruma_events_macros::EventContent;
use ruma_identifiers::TransactionId; use ruma_identifiers::TransactionId;
use ruma_macros::EventContent;
use ruma_serde::StringEnum; use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.key.verification.done`]: https://spec.matrix.org/v1.2/client-server-api/#mkeyverificationdone //! [`m.key.verification.done`]: https://spec.matrix.org/v1.2/client-server-api/#mkeyverificationdone
use ruma_events_macros::EventContent;
use ruma_identifiers::TransactionId; use ruma_identifiers::TransactionId;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::Relation; use super::Relation;

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.key.verification.key`]: https://spec.matrix.org/v1.2/client-server-api/#mkeyverificationkey //! [`m.key.verification.key`]: https://spec.matrix.org/v1.2/client-server-api/#mkeyverificationkey
use ruma_events_macros::EventContent;
use ruma_identifiers::TransactionId; use ruma_identifiers::TransactionId;
use ruma_macros::EventContent;
use ruma_serde::Base64; use ruma_serde::Base64;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -4,8 +4,8 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_events_macros::EventContent;
use ruma_identifiers::TransactionId; use ruma_identifiers::TransactionId;
use ruma_macros::EventContent;
use ruma_serde::Base64; use ruma_serde::Base64;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.key.verification.ready`]: https://spec.matrix.org/v1.2/client-server-api/#mkeyverificationready //! [`m.key.verification.ready`]: https://spec.matrix.org/v1.2/client-server-api/#mkeyverificationready
use ruma_events_macros::EventContent;
use ruma_identifiers::{DeviceId, TransactionId}; use ruma_identifiers::{DeviceId, TransactionId};
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::{Relation, VerificationMethod}; use super::{Relation, VerificationMethod};

View File

@ -3,8 +3,8 @@
//! [`m.key.verification.request`]: https://spec.matrix.org/v1.2/client-server-api/#mkeyverificationrequest //! [`m.key.verification.request`]: https://spec.matrix.org/v1.2/client-server-api/#mkeyverificationrequest
use ruma_common::MilliSecondsSinceUnixEpoch; use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events_macros::EventContent;
use ruma_identifiers::{DeviceId, TransactionId}; use ruma_identifiers::{DeviceId, TransactionId};
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::VerificationMethod; use super::VerificationMethod;

View File

@ -4,8 +4,8 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_events_macros::EventContent;
use ruma_identifiers::{DeviceId, TransactionId}; use ruma_identifiers::{DeviceId, TransactionId};
use ruma_macros::EventContent;
use ruma_serde::Base64; use ruma_serde::Base64;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;

View File

@ -166,7 +166,7 @@ pub mod exports {
/// Re-export of all the derives needed to create your own event types. /// Re-export of all the derives needed to create your own event types.
pub mod macros { pub mod macros {
pub use ruma_events_macros::{Event, EventContent}; pub use ruma_macros::{Event, EventContent};
} }
pub mod call; pub mod call;

View File

@ -2,7 +2,7 @@
//! //!
//! [`m.policy.rule.room`]: https://spec.matrix.org/v1.2/client-server-api/#mpolicyruleroom //! [`m.policy.rule.room`]: https://spec.matrix.org/v1.2/client-server-api/#mpolicyruleroom
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::policy::rule::PolicyRuleEventContent; use crate::policy::rule::PolicyRuleEventContent;

View File

@ -2,7 +2,7 @@
//! //!
//! [`m.policy.rule.server`]: https://spec.matrix.org/v1.2/client-server-api/#mpolicyruleserver //! [`m.policy.rule.server`]: https://spec.matrix.org/v1.2/client-server-api/#mpolicyruleserver
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::policy::rule::PolicyRuleEventContent; use crate::policy::rule::PolicyRuleEventContent;

View File

@ -2,7 +2,7 @@
//! //!
//! [`m.policy.rule.user`]: https://spec.matrix.org/v1.2/client-server-api/#mpolicyruleuser //! [`m.policy.rule.user`]: https://spec.matrix.org/v1.2/client-server-api/#mpolicyruleuser
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::policy::rule::PolicyRuleEventContent; use crate::policy::rule::PolicyRuleEventContent;

View File

@ -4,8 +4,8 @@
use js_int::UInt; use js_int::UInt;
use ruma_common::presence::PresenceState; use ruma_common::presence::PresenceState;
use ruma_events_macros::{Event, EventContent};
use ruma_identifiers::{MxcUri, UserId}; use ruma_identifiers::{MxcUri, UserId};
use ruma_macros::{Event, EventContent};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{EventKind, StaticEventContent}; use crate::{EventKind, StaticEventContent};

View File

@ -3,7 +3,7 @@
//! [`m.push_rules`]: https://spec.matrix.org/v1.2/client-server-api/#mpush_rules //! [`m.push_rules`]: https://spec.matrix.org/v1.2/client-server-api/#mpush_rules
use ruma_common::push::Ruleset; use ruma_common::push::Ruleset;
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.push_rules` event. /// The content of an `m.push_rules` event.

View File

@ -1,7 +1,7 @@
//! Types for the `m.reaction` event. //! Types for the `m.reaction` event.
use ruma_events_macros::EventContent;
use ruma_identifiers::EventId; use ruma_identifiers::EventId;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The payload for a `m.reaction` event. /// The payload for a `m.reaction` event.

View File

@ -8,8 +8,8 @@ use std::{
}; };
use ruma_common::{receipt::ReceiptType, MilliSecondsSinceUnixEpoch}; use ruma_common::{receipt::ReceiptType, MilliSecondsSinceUnixEpoch};
use ruma_events_macros::EventContent;
use ruma_identifiers::{EventId, UserId}; use ruma_identifiers::{EventId, UserId};
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.receipt` event. /// The content of an `m.receipt` event.

View File

@ -1,7 +1,7 @@
//! Types for the `m.room.aliases` event. //! Types for the `m.room.aliases` event.
use ruma_events_macros::EventContent;
use ruma_identifiers::{RoomAliasId, RoomVersionId}; use ruma_identifiers::{RoomAliasId, RoomVersionId};
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::value::RawValue as RawJsonValue; use serde_json::value::RawValue as RawJsonValue;

View File

@ -3,8 +3,8 @@
//! [`m.room.avatar`]: https://spec.matrix.org/v1.2/client-server-api/#mroomavatar //! [`m.room.avatar`]: https://spec.matrix.org/v1.2/client-server-api/#mroomavatar
use js_int::UInt; use js_int::UInt;
use ruma_events_macros::EventContent;
use ruma_identifiers::MxcUri; use ruma_identifiers::MxcUri;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::ThumbnailInfo; use super::ThumbnailInfo;

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.room.canonical_alias`]: https://spec.matrix.org/v1.2/client-server-api/#mroomcanonical_alias //! [`m.room.canonical_alias`]: https://spec.matrix.org/v1.2/client-server-api/#mroomcanonical_alias
use ruma_events_macros::EventContent;
use ruma_identifiers::RoomAliasId; use ruma_identifiers::RoomAliasId;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.room.canonical_alias` event. /// The content of an `m.room.canonical_alias` event.

View File

@ -3,8 +3,8 @@
//! [`m.room.create`]: https://spec.matrix.org/v1.2/client-server-api/#mroomcreate //! [`m.room.create`]: https://spec.matrix.org/v1.2/client-server-api/#mroomcreate
use ruma_common::room::RoomType; use ruma_common::room::RoomType;
use ruma_events_macros::EventContent;
use ruma_identifiers::{EventId, RoomId, RoomVersionId, UserId}; use ruma_identifiers::{EventId, RoomId, RoomVersionId, UserId};
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.room.create` event. /// The content of an `m.room.create` event.

View File

@ -5,8 +5,8 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use js_int::UInt; use js_int::UInt;
use ruma_events_macros::EventContent;
use ruma_identifiers::{DeviceId, EventId}; use ruma_identifiers::{DeviceId, EventId};
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::room::message::InReplyTo; use crate::room::message::InReplyTo;

View File

@ -3,7 +3,7 @@
//! [`m.room.encryption`]: https://spec.matrix.org/v1.2/client-server-api/#mroomencryption //! [`m.room.encryption`]: https://spec.matrix.org/v1.2/client-server-api/#mroomencryption
use js_int::UInt; use js_int::UInt;
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::EventEncryptionAlgorithm; use crate::EventEncryptionAlgorithm;

View File

@ -2,7 +2,7 @@
//! //!
//! [`m.room.guest_access`]: https://spec.matrix.org/v1.2/client-server-api/#mroomguest_access //! [`m.room.guest_access`]: https://spec.matrix.org/v1.2/client-server-api/#mroomguest_access
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use ruma_serde::StringEnum; use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -2,7 +2,7 @@
//! //!
//! [`m.room.history_visibility`]: https://spec.matrix.org/v1.2/client-server-api/#mroomhistory_visibility //! [`m.room.history_visibility`]: https://spec.matrix.org/v1.2/client-server-api/#mroomhistory_visibility
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use ruma_serde::StringEnum; use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -4,8 +4,8 @@
use std::{borrow::Cow, collections::BTreeMap}; use std::{borrow::Cow, collections::BTreeMap};
use ruma_events_macros::EventContent;
use ruma_identifiers::RoomId; use ruma_identifiers::RoomId;
use ruma_macros::EventContent;
use ruma_serde::from_raw_json_value; use ruma_serde::from_raw_json_value;
use serde::{ use serde::{
de::{Deserializer, Error}, de::{Deserializer, Error},

View File

@ -4,8 +4,8 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_events_macros::EventContent;
use ruma_identifiers::{MxcUri, RoomVersionId, ServerName, ServerSigningKeyId, UserId}; use ruma_identifiers::{MxcUri, RoomVersionId, ServerName, ServerSigningKeyId, UserId};
use ruma_macros::EventContent;
use ruma_serde::StringEnum; use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::value::RawValue as RawJsonValue; use serde_json::value::RawValue as RawJsonValue;

View File

@ -5,8 +5,8 @@
use std::{borrow::Cow, fmt}; use std::{borrow::Cow, fmt};
use js_int::UInt; use js_int::UInt;
use ruma_events_macros::EventContent;
use ruma_identifiers::{DeviceId, EventId, MxcUri, UserId}; use ruma_identifiers::{DeviceId, EventId, MxcUri, UserId};
use ruma_macros::EventContent;
use ruma_serde::{JsonObject, StringEnum}; use ruma_serde::{JsonObject, StringEnum};
use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.room.message.feedback`]: https://spec.matrix.org/v1.2/client-server-api/#mroommessagefeedback //! [`m.room.message.feedback`]: https://spec.matrix.org/v1.2/client-server-api/#mroommessagefeedback
use ruma_events_macros::EventContent;
use ruma_identifiers::EventId; use ruma_identifiers::EventId;
use ruma_macros::EventContent;
use ruma_serde::StringEnum; use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.room.name`]: https://spec.matrix.org/v1.2/client-server-api/#mroomname //! [`m.room.name`]: https://spec.matrix.org/v1.2/client-server-api/#mroomname
use ruma_events_macros::EventContent;
use ruma_identifiers::RoomName; use ruma_identifiers::RoomName;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.room.name` event. /// The content of an `m.room.name` event.

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.room.pinned_events`]: https://spec.matrix.org/v1.2/client-server-api/#mroompinned_events //! [`m.room.pinned_events`]: https://spec.matrix.org/v1.2/client-server-api/#mroompinned_events
use ruma_events_macros::EventContent;
use ruma_identifiers::EventId; use ruma_identifiers::EventId;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.room.pinned_events` event. /// The content of an `m.room.pinned_events` event.

View File

@ -6,8 +6,8 @@ use std::collections::BTreeMap;
use js_int::{int, Int}; use js_int::{int, Int};
use ruma_common::power_levels::{default_power_level, NotificationPowerLevels}; use ruma_common::power_levels::{default_power_level, NotificationPowerLevels};
use ruma_events_macros::EventContent;
use ruma_identifiers::UserId; use ruma_identifiers::UserId;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::EventType; use crate::EventType;

View File

@ -3,8 +3,8 @@
//! [`m.room.redaction`]: https://spec.matrix.org/v1.2/client-server-api/#mroomredaction //! [`m.room.redaction`]: https://spec.matrix.org/v1.2/client-server-api/#mroomredaction
use ruma_common::MilliSecondsSinceUnixEpoch; use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events_macros::{Event, EventContent};
use ruma_identifiers::{EventId, RoomId, UserId}; use ruma_identifiers::{EventId, RoomId, UserId};
use ruma_macros::{Event, EventContent};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{Redact, RedactContent, RedactedUnsigned, Unsigned}; use crate::{Redact, RedactContent, RedactedUnsigned, Unsigned};

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.room.server_acl`]: https://spec.matrix.org/v1.2/client-server-api/#mroomserver_acl //! [`m.room.server_acl`]: https://spec.matrix.org/v1.2/client-server-api/#mroomserver_acl
use ruma_events_macros::EventContent;
use ruma_identifiers::ServerName; use ruma_identifiers::ServerName;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use wildmatch::WildMatch; use wildmatch::WildMatch;

View File

@ -2,7 +2,7 @@
//! //!
//! [`m.room.third_party_invite`]: https://spec.matrix.org/v1.2/client-server-api/#mroomthird_party_invite //! [`m.room.third_party_invite`]: https://spec.matrix.org/v1.2/client-server-api/#mroomthird_party_invite
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use ruma_serde::Base64; use ruma_serde::Base64;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.room.tombstone`]: https://spec.matrix.org/v1.2/client-server-api/#mroomtombstone //! [`m.room.tombstone`]: https://spec.matrix.org/v1.2/client-server-api/#mroomtombstone
use ruma_events_macros::EventContent;
use ruma_identifiers::RoomId; use ruma_identifiers::RoomId;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.room.tombstone` event. /// The content of an `m.room.tombstone` event.

View File

@ -2,7 +2,7 @@
//! //!
//! [`m.room.topic`]: https://spec.matrix.org/v1.2/client-server-api/#mroomtopic //! [`m.room.topic`]: https://spec.matrix.org/v1.2/client-server-api/#mroomtopic
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.room.topic` event. /// The content of an `m.room.topic` event.

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.room_key`]: https://spec.matrix.org/v1.2/client-server-api/#mroom_key //! [`m.room_key`]: https://spec.matrix.org/v1.2/client-server-api/#mroom_key
use ruma_events_macros::EventContent;
use ruma_identifiers::{EventEncryptionAlgorithm, RoomId}; use ruma_identifiers::{EventEncryptionAlgorithm, RoomId};
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.room_key` event. /// The content of an `m.room_key` event.

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.room_key_request`]: https://spec.matrix.org/v1.2/client-server-api/#mroom_key_request //! [`m.room_key_request`]: https://spec.matrix.org/v1.2/client-server-api/#mroom_key_request
use ruma_events_macros::EventContent;
use ruma_identifiers::{DeviceId, EventEncryptionAlgorithm, RoomId, TransactionId}; use ruma_identifiers::{DeviceId, EventEncryptionAlgorithm, RoomId, TransactionId};
use ruma_macros::EventContent;
use ruma_serde::StringEnum; use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -4,8 +4,8 @@
use std::convert::TryFrom; use std::convert::TryFrom;
use ruma_events_macros::EventContent;
use ruma_identifiers::{DeviceId, TransactionId}; use ruma_identifiers::{DeviceId, TransactionId};
use ruma_macros::EventContent;
use ruma_serde::StringEnum; use ruma_serde::StringEnum;
use serde::{ser::SerializeStruct, Deserialize, Serialize}; use serde::{ser::SerializeStruct, Deserialize, Serialize};

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.secret.send`]: https://spec.matrix.org/v1.2/client-server-api/#msecretsend //! [`m.secret.send`]: https://spec.matrix.org/v1.2/client-server-api/#msecretsend
use ruma_events_macros::EventContent;
use ruma_identifiers::TransactionId; use ruma_identifiers::TransactionId;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.secret.send` event. /// The content of an `m.secret.send` event.

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.space.child`]: https://spec.matrix.org/v1.2/client-server-api/#mspacechild //! [`m.space.child`]: https://spec.matrix.org/v1.2/client-server-api/#mspacechild
use ruma_events_macros::EventContent;
use ruma_identifiers::ServerName; use ruma_identifiers::ServerName;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.space.child` event. /// The content of an `m.space.child` event.

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.space.parent`]: https://spec.matrix.org/v1.2/client-server-api/#mspaceparent //! [`m.space.parent`]: https://spec.matrix.org/v1.2/client-server-api/#mspaceparent
use ruma_events_macros::EventContent;
use ruma_identifiers::ServerName; use ruma_identifiers::ServerName;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.space.parent` event. /// The content of an `m.space.parent` event.

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.sticker`]: https://spec.matrix.org/v1.2/client-server-api/#msticker //! [`m.sticker`]: https://spec.matrix.org/v1.2/client-server-api/#msticker
use ruma_events_macros::EventContent;
use ruma_identifiers::MxcUri; use ruma_identifiers::MxcUri;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::room::ImageInfo; use crate::room::ImageInfo;

View File

@ -4,7 +4,7 @@
use std::{collections::BTreeMap, error::Error, fmt, str::FromStr}; use std::{collections::BTreeMap, error::Error, fmt, str::FromStr};
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use ruma_serde::deserialize_cow_str; use ruma_serde::deserialize_cow_str;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -2,8 +2,8 @@
//! //!
//! [`m.typing`]: https://spec.matrix.org/v1.2/client-server-api/#mtyping //! [`m.typing`]: https://spec.matrix.org/v1.2/client-server-api/#mtyping
use ruma_events_macros::EventContent;
use ruma_identifiers::UserId; use ruma_identifiers::UserId;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The content of an `m.typing` event. /// The content of an `m.typing` event.

View File

@ -1,4 +1,4 @@
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[derive(Clone, Debug, Deserialize, Serialize, EventContent)]

View File

@ -1,4 +1,4 @@
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[derive(Clone, Debug, Deserialize, Serialize, EventContent)]

View File

@ -1,4 +1,4 @@
use ruma_events_macros::EventContent; use ruma_macros::EventContent;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)] #[derive(Clone, Debug, Deserialize, Serialize, EventContent)]

View File

@ -5,7 +5,7 @@ extern crate serde;
use ruma_common::MilliSecondsSinceUnixEpoch; use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::{StateEventContent, Unsigned}; use ruma_events::{StateEventContent, Unsigned};
use ruma_events_macros::Event; use ruma_macros::Event;
use ruma_identifiers::{EventId, RoomId, UserId}; use ruma_identifiers::{EventId, RoomId, UserId};
/// State event. /// State event.

View File

@ -1,5 +1,5 @@
use ruma_events::StateEventContent; use ruma_events::StateEventContent;
use ruma_events_macros::Event; use ruma_macros::Event;
/// State event. /// State event.
#[derive(Clone, Debug, Event)] #[derive(Clone, Debug, Event)]

View File

@ -1,5 +1,5 @@
use ruma_events::StateEventContent; use ruma_events::StateEventContent;
use ruma_events_macros::Event; use ruma_macros::Event;
/// State event. /// State event.
#[derive(Clone, Debug, Event)] #[derive(Clone, Debug, Event)]

View File

@ -1,4 +1,4 @@
use ruma_events_macros::event_enum; use ruma_macros::event_enum;
event_enum! { event_enum! {
/// Any global account data event. /// Any global account data event.

View File

@ -1,4 +1,4 @@
use ruma_events_macros::event_enum; use ruma_macros::event_enum;
event_enum! { event_enum! {
enum State { enum State {

View File

@ -1,4 +1,4 @@
use ruma_events_macros::event_enum; use ruma_macros::event_enum;
event_enum! { event_enum! {
enum NotReal { enum NotReal {

View File

@ -1,14 +1,14 @@
[package] [package]
categories = ["api-bindings", "web-programming"] categories = ["api-bindings", "web-programming"]
description = "A procedural macro used by the ruma-events crate." description = "Procedural macros used by the Ruma crates."
edition = "2018" edition = "2018"
homepage = "https://www.ruma.io/" homepage = "https://www.ruma.io/"
keywords = ["matrix", "chat", "messaging", "ruma"] keywords = ["matrix", "chat", "messaging", "ruma"]
license = "MIT" license = "MIT"
name = "ruma-events-macros" name = "ruma-macros"
readme = "README.md" readme = "README.md"
repository = "https://github.com/ruma/ruma" repository = "https://github.com/ruma/ruma"
version = "0.26.0" version = "0.1.0"
[lib] [lib]
proc-macro = true proc-macro = true

View File

@ -0,0 +1,5 @@
# ruma-macros
**ruma-macros** provides procedural macros for easily generating types for [Ruma] crates.
[Ruma]: https://github.com/ruma/ruma/

View File

@ -0,0 +1,10 @@
//! Methods and types for generating [ruma-events] events.
//!
//! [ruma-events]: https://github.com/ruma/ruma/tree/main/ruma-events
pub mod event;
pub mod event_content;
pub mod event_enum;
pub mod event_parse;
pub mod event_type;
mod util;

View File

@ -7,11 +7,11 @@ use syn::{
Meta, MetaList, NestedMeta, Meta, MetaList, NestedMeta,
}; };
use crate::{ use super::{
event_parse::{to_kind_variation, EventKind, EventKindVariation}, event_parse::{to_kind_variation, EventKind, EventKindVariation},
import_ruma_events,
util::is_non_stripped_room_event, util::is_non_stripped_room_event,
}; };
use crate::import_ruma_events;
/// Derive `Event` macro code generation. /// Derive `Event` macro code generation.
pub fn expand_event(input: DeriveInput) -> syn::Result<TokenStream> { pub fn expand_event(input: DeriveInput) -> syn::Result<TokenStream> {

View File

@ -9,7 +9,7 @@ use syn::{
DeriveInput, Ident, LitStr, Token, DeriveInput, Ident, LitStr, Token,
}; };
use crate::event_parse::{EventKind, EventKindVariation}; use super::event_parse::{EventKind, EventKindVariation};
mod kw { mod kw {
// This `content` field is kept when the event is redacted. // This `content` field is kept when the event is redacted.

View File

@ -4,7 +4,7 @@ use proc_macro2::{Span, TokenStream};
use quote::{format_ident, quote, ToTokens}; use quote::{format_ident, quote, ToTokens};
use syn::{Attribute, Data, DataEnum, DeriveInput, Ident, LitStr}; use syn::{Attribute, Data, DataEnum, DeriveInput, Ident, LitStr};
use crate::{ use super::{
event_parse::{EventEnumDecl, EventEnumEntry, EventKind, EventKindVariation}, event_parse::{EventEnumDecl, EventEnumEntry, EventKind, EventKindVariation},
util::{has_prev_content_field, EVENT_FIELDS}, util::{has_prev_content_field, EVENT_FIELDS},
}; };
@ -618,7 +618,7 @@ fn field_return_type(
quote! { #ruma_events::Unsigned } quote! { #ruma_events::Unsigned }
} }
} }
_ => panic!("the `ruma_events_macros::event_enum::EVENT_FIELD` const was changed"), _ => panic!("the `ruma_macros::event_enum::EVENT_FIELD` const was changed"),
} }
} }

View File

@ -2,7 +2,7 @@ use proc_macro2::{Span, TokenStream};
use quote::{format_ident, quote}; use quote::{format_ident, quote};
use syn::{Ident, LitStr}; use syn::{Ident, LitStr};
use crate::event_parse::{EventEnumEntry, EventEnumInput, EventKind}; use super::event_parse::{EventEnumEntry, EventEnumInput, EventKind};
pub fn expand_event_type_enum( pub fn expand_event_type_enum(
input: EventEnumInput, input: EventEnumInput,

View File

@ -1,4 +1,4 @@
use crate::event_parse::{EventKind, EventKindVariation}; use super::event_parse::{EventKind, EventKindVariation};
pub(crate) fn is_non_stripped_room_event(kind: EventKind, var: EventKindVariation) -> bool { pub(crate) fn is_non_stripped_room_event(kind: EventKind, var: EventKindVariation) -> bool {
matches!(kind, EventKind::MessageLike | EventKind::State) matches!(kind, EventKind::MessageLike | EventKind::State)

View File

@ -1,33 +1,26 @@
#![doc(html_favicon_url = "https://www.ruma.io/favicon.ico")] #![doc(html_favicon_url = "https://www.ruma.io/favicon.ico")]
#![doc(html_logo_url = "https://www.ruma.io/images/logo.png")] #![doc(html_logo_url = "https://www.ruma.io/images/logo.png")]
//! A procedural macro for generating [ruma-events] events. //! Procedural macros used by ruma crates.
//! //!
//! See the documentation for the individual macros for usage details. //! See the documentation for the individual macros for usage details.
//!
//! [ruma-events]: https://github.com/ruma/ruma/tree/main/ruma-events
#![warn(missing_docs)] #![warn(missing_docs)]
use event_parse::EventEnumInput;
use proc_macro::TokenStream; use proc_macro::TokenStream;
use proc_macro2 as pm2; use proc_macro2 as pm2;
use proc_macro_crate::{crate_name, FoundCrate}; use proc_macro_crate::{crate_name, FoundCrate};
use quote::{format_ident, quote}; use quote::{format_ident, quote};
use syn::{parse_macro_input, DeriveInput}; use syn::{parse_macro_input, DeriveInput};
use self::{ use self::events::{
event::expand_event, event::expand_event,
event_content::expand_event_content, event_content::expand_event_content,
event_enum::{expand_event_enums, expand_from_impls_derived}, event_enum::{expand_event_enums, expand_from_impls_derived},
event_parse::EventEnumInput,
event_type::expand_event_type_enum, event_type::expand_event_type_enum,
}; };
mod event; mod events;
mod event_content;
mod event_enum;
mod event_parse;
mod event_type;
mod util;
/// Generates an enum to represent the various Matrix event types. /// Generates an enum to represent the various Matrix event types.
/// ///
@ -38,7 +31,7 @@ mod util;
/// ///
/// ```ignore /// ```ignore
/// # // HACK: This is "ignore" because of cyclical dependency drama. /// # // HACK: This is "ignore" because of cyclical dependency drama.
/// use ruma_events_macros::event_enum; /// use ruma_macros::event_enum;
/// ///
/// event_enum! { /// event_enum! {
/// enum ToDevice { /// enum ToDevice {