common: Derive Debug via StringEnum derive

This commit is contained in:
Jonas Platte 2023-01-13 13:49:59 +01:00
parent 625d5a0782
commit b859d9c8b0
No known key found for this signature in database
GPG Key ID: AAA7A61F696C3E0C
47 changed files with 77 additions and 61 deletions

View File

@ -45,7 +45,7 @@ impl IdentityServerInfo {
/// Possible values for deleting or unbinding 3PIDs. /// Possible values for deleting or unbinding 3PIDs.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, StringEnum)] #[derive(Clone, StringEnum)]
#[ruma_enum(rename_all = "kebab-case")] #[ruma_enum(rename_all = "kebab-case")]
#[non_exhaustive] #[non_exhaustive]
pub enum ThirdPartyIdRemovalStatus { pub enum ThirdPartyIdRemovalStatus {

View File

@ -199,7 +199,7 @@ impl Default for RoomVersionsCapability {
/// The stability of a room version. /// The stability of a room version.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "lowercase")] #[ruma_enum(rename_all = "lowercase")]
#[non_exhaustive] #[non_exhaustive]
pub enum RoomVersionStability { pub enum RoomVersionStability {

View File

@ -16,7 +16,7 @@ pub use self::{lazy_load::LazyLoadOptions, url::UrlFilter};
/// Format to use for returned events. /// Format to use for returned events.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, Default, PartialEq, Eq, StringEnum)] #[derive(Clone, Default, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum EventFormat { pub enum EventFormat {

View File

@ -106,7 +106,7 @@ pub mod v3 {
/// Error code for signed key processing failures. /// Error code for signed key processing failures.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
#[ruma_enum(rename_all = "M_MATRIX_ERROR_CASE")] #[ruma_enum(rename_all = "M_MATRIX_ERROR_CASE")]
pub enum FailureErrorCode { pub enum FailureErrorCode {

View File

@ -145,7 +145,7 @@ pub mod v3 {
/// The desired resizing method. /// The desired resizing method.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, StringEnum)] #[derive(Clone, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum Method { pub enum Method {

View File

@ -82,7 +82,7 @@ pub mod v3 {
/// The kind of membership events to filter for. /// The kind of membership events to filter for.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "lowercase")] #[ruma_enum(rename_all = "lowercase")]
#[non_exhaustive] #[non_exhaustive]
pub enum MembershipEventFilter { pub enum MembershipEventFilter {

View File

@ -301,7 +301,7 @@ pub struct CustomPusherData {
/// The scope of a push rule. /// The scope of a push rule.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "lowercase")] #[ruma_enum(rename_all = "lowercase")]
#[non_exhaustive] #[non_exhaustive]
pub enum RuleScope { pub enum RuleScope {

View File

@ -81,7 +81,7 @@ pub mod v3 {
/// The type of receipt. /// The type of receipt.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialOrdAsRefStr, OrdAsRefStr, PartialEqAsRefStr, Eq, StringEnum)] #[derive(Clone, PartialOrdAsRefStr, OrdAsRefStr, PartialEqAsRefStr, Eq, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum ReceiptType { pub enum ReceiptType {
/// A [public read receipt]. /// A [public read receipt].

View File

@ -14,7 +14,7 @@ use crate::PrivOwnedStr;
/// Whether or not a newly created room will be listed in the room directory. /// Whether or not a newly created room will be listed in the room directory.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, Default, PartialEq, Eq, StringEnum)] #[derive(Clone, Default, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum Visibility { pub enum Visibility {

View File

@ -184,7 +184,7 @@ pub mod v3 {
/// A convenience parameter for setting a few default state events. /// A convenience parameter for setting a few default state events.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum RoomPreset { pub enum RoomPreset {

View File

@ -250,7 +250,7 @@ pub mod v3 {
/// The key within events to use for this grouping. /// The key within events to use for this grouping.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum GroupingKey { pub enum GroupingKey {
@ -287,7 +287,7 @@ pub mod v3 {
/// The keys to search for. /// The keys to search for.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum SearchKeys { pub enum SearchKeys {
/// content.body /// content.body
@ -308,7 +308,7 @@ pub mod v3 {
/// The order in which to search for results. /// The order in which to search for results.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum OrderBy { pub enum OrderBy {

View File

@ -202,7 +202,7 @@ pub mod v3 {
/// ///
/// [matrix-spec-proposals]: https://github.com/matrix-org/matrix-spec-proposals/blob/v1.1/informal/idp-brands.md /// [matrix-spec-proposals]: https://github.com/matrix-org/matrix-spec-proposals/blob/v1.1/informal/idp-brands.md
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub enum IdentityProviderBrand { pub enum IdentityProviderBrand {
/// The [Apple] brand. /// The [Apple] brand.

View File

@ -142,7 +142,7 @@ impl From<SpaceHierarchyRoomsChunkInit> for SpaceHierarchyRoomsChunk {
/// enum does not hold the conditions for joining restricted rooms. Instead, the server is assumed /// enum does not hold the conditions for joining restricted rooms. Instead, the server is assumed
/// to only return rooms the user is allowed to join in a space hierarchy listing response. /// to only return rooms the user is allowed to join in a space hierarchy listing response.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, Default, PartialEq, Eq, StringEnum)] #[derive(Clone, Default, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub enum SpaceRoomJoinRule { pub enum SpaceRoomJoinRule {

View File

@ -88,7 +88,7 @@ pub mod v1 {
/// Which threads to include in the response. /// Which threads to include in the response.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, StringEnum)] #[derive(Clone, Default, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
#[ruma_enum(rename_all = "lowercase")] #[ruma_enum(rename_all = "lowercase")]
#[non_exhaustive] #[non_exhaustive]
pub enum IncludeThreads { pub enum IncludeThreads {

View File

@ -221,7 +221,7 @@ impl<'de> Deserialize<'de> for AuthData {
/// The type of an authentication stage. /// The type of an authentication stage.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum AuthType { pub enum AuthType {
/// Password-based authentication (`m.login.password`). /// Password-based authentication (`m.login.password`).

View File

@ -57,6 +57,7 @@ Breaking changes:
* Instead, use `.deserialize_as::<T>()` or `.cast_ref::<T>().deserialize_with_type()` * Instead, use `.deserialize_as::<T>()` or `.cast_ref::<T>().deserialize_with_type()`
* Remove `EventContent::from_parts` * Remove `EventContent::from_parts`
* Replace it with `EventContentFromType::from_parts` * Replace it with `EventContentFromType::from_parts`
* The `serde::StringEnum` derive now also generates a `Debug` implementation
Improvements: Improvements:

View File

@ -4,7 +4,7 @@ use crate::{serde::StringEnum, PrivOwnedStr};
/// Access token types. /// Access token types.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum TokenType { pub enum TokenType {
/// Bearer token type /// Bearer token type

View File

@ -155,7 +155,7 @@ pub enum RoomNetwork {
/// The rule used for users wishing to join a public room. /// The rule used for users wishing to join a public room.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, Default, PartialEq, Eq, StringEnum)] #[derive(Clone, Default, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub enum PublicRoomJoinRule { pub enum PublicRoomJoinRule {

View File

@ -156,7 +156,7 @@ impl CrossSigningKey {
/// The usage of a cross signing key. /// The usage of a cross signing key.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, StringEnum)] #[derive(Clone, StringEnum)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum KeyUsage { pub enum KeyUsage {

View File

@ -50,7 +50,7 @@ impl SessionDescription {
/// ///
/// [`RTCSdpType`]: (https://www.w3.org/TR/webrtc/#dom-rtcsdptype): /// [`RTCSdpType`]: (https://www.w3.org/TR/webrtc/#dom-rtcsdptype):
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "lowercase")] #[ruma_enum(rename_all = "lowercase")]
#[non_exhaustive] #[non_exhaustive]
pub enum SessionDescriptionType { pub enum SessionDescriptionType {

View File

@ -85,7 +85,7 @@ impl CallHangupEventContent {
/// in the call negotiation, this should be `ice_failed` for when ICE negotiation fails or /// in the call negotiation, this should be `ice_failed` for when ICE negotiation fails or
/// `invite_timeout` for when the other party did not answer in time. /// `invite_timeout` for when the other party did not answer in time.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[cfg_attr(feature = "unstable-msc2746", derive(Default))] #[cfg_attr(feature = "unstable-msc2746", derive(Default))]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]

View File

@ -20,7 +20,7 @@ pub mod start;
/// A hash algorithm. /// A hash algorithm.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum HashAlgorithm { pub enum HashAlgorithm {
@ -33,7 +33,7 @@ pub enum HashAlgorithm {
/// A key agreement protocol. /// A key agreement protocol.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "kebab-case")] #[ruma_enum(rename_all = "kebab-case")]
#[non_exhaustive] #[non_exhaustive]
pub enum KeyAgreementProtocol { pub enum KeyAgreementProtocol {
@ -49,7 +49,7 @@ pub enum KeyAgreementProtocol {
/// A message authentication code algorithm. /// A message authentication code algorithm.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "kebab-case")] #[ruma_enum(rename_all = "kebab-case")]
#[non_exhaustive] #[non_exhaustive]
pub enum MessageAuthenticationCode { pub enum MessageAuthenticationCode {
@ -70,7 +70,7 @@ pub enum MessageAuthenticationCode {
/// A Short Authentication String method. /// A Short Authentication String method.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum ShortAuthenticationString { pub enum ShortAuthenticationString {
@ -86,7 +86,7 @@ pub enum ShortAuthenticationString {
/// A Short Authentication String (SAS) verification method. /// A Short Authentication String (SAS) verification method.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum VerificationMethod { pub enum VerificationMethod {
/// The `m.sas.v1` verification method. /// The `m.sas.v1` verification method.

View File

@ -66,7 +66,7 @@ impl KeyVerificationCancelEventContent {
/// Custom error codes should use the Java package naming convention. /// Custom error codes should use the Java package naming convention.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
// FIXME: Add `m.foo_bar` as a naming scheme in StringEnum and remove rename attributes. // FIXME: Add `m.foo_bar` as a naming scheme in StringEnum and remove rename attributes.
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum CancelCode { pub enum CancelCode {
/// The user cancelled the verification. /// The user cancelled the verification.

View File

@ -157,7 +157,7 @@ impl AssetContent {
/// The type of an asset. /// The type of an asset.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, StringEnum)] #[derive(Clone, Default, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum AssetType { pub enum AssetType {
/// The asset is the sender of the event. /// The asset is the sender of the event.

View File

@ -56,7 +56,7 @@ pub struct PossiblyRedactedPolicyRuleEventContent {
/// The possible actions that can be taken. /// The possible actions that can be taken.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum Recommendation { pub enum Recommendation {
/// Entities affected by the rule should be banned from participation where possible. /// Entities affected by the rule should be banned from participation where possible.

View File

@ -74,7 +74,7 @@ impl PollStartContent {
/// The kind of poll. /// The kind of poll.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, Default, PartialEq, Eq, StringEnum)] #[derive(Clone, Default, PartialEq, Eq, StringEnum)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub enum PollKind { pub enum PollKind {
/// The results are revealed once the poll is closed. /// The results are revealed once the poll is closed.

View File

@ -59,7 +59,7 @@ pub type Receipts = BTreeMap<ReceiptType, UserReceipts>;
/// The type of receipt. /// The type of receipt.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialOrdAsRefStr, OrdAsRefStr, PartialEqAsRefStr, Eq, StringEnum)] #[derive(Clone, PartialOrdAsRefStr, OrdAsRefStr, PartialEqAsRefStr, Eq, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum ReceiptType { pub enum ReceiptType {
/// A [public read receipt]. /// A [public read receipt].

View File

@ -93,7 +93,7 @@ impl BundledAnnotation {
/// Type of annotation. /// Type of annotation.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[cfg(feature = "unstable-msc2677")] #[cfg(feature = "unstable-msc2677")]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub enum AnnotationType { pub enum AnnotationType {
@ -333,7 +333,7 @@ impl BundledRelations {
/// Relation types as defined in `rel_type` of an `m.relates_to` field. /// Relation types as defined in `rel_type` of an `m.relates_to` field.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "m.snake_case")] #[ruma_enum(rename_all = "m.snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum RelationType { pub enum RelationType {

View File

@ -50,7 +50,7 @@ impl SyncRoomGuestAccessEvent {
/// A policy for guest user access to a room. /// A policy for guest user access to a room.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum GuestAccess { pub enum GuestAccess {

View File

@ -49,7 +49,7 @@ impl SyncRoomHistoryVisibilityEvent {
/// Who can see a room's history. /// Who can see a room's history.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum HistoryVisibility { pub enum HistoryVisibility {

View File

@ -272,7 +272,7 @@ impl SyncRoomMemberEvent {
/// The membership state of a user. /// The membership state of a user.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "lowercase")] #[ruma_enum(rename_all = "lowercase")]
#[non_exhaustive] #[non_exhaustive]
pub enum MembershipState { pub enum MembershipState {

View File

@ -595,7 +595,7 @@ pub enum Relation<C> {
/// The format for the formatted representation of a message body. /// The format for the formatted representation of a message body.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum MessageFormat { pub enum MessageFormat {
/// HTML. /// HTML.

View File

@ -35,7 +35,7 @@ impl ServerNoticeMessageEventContent {
/// Types of server notices. /// Types of server notices.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum ServerNoticeType { pub enum ServerNoticeType {
/// The server has exceeded some limit which requires the server administrator to intervene. /// The server has exceeded some limit which requires the server administrator to intervene.
@ -48,7 +48,7 @@ pub enum ServerNoticeType {
/// Types of usage limits. /// Types of usage limits.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum LimitType { pub enum LimitType {

View File

@ -48,7 +48,7 @@ impl ToDeviceRoomKeyRequestEventContent {
/// A new key request or a cancellation of a previous request. /// A new key request or a cancellation of a previous request.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum Action { pub enum Action {

View File

@ -109,7 +109,7 @@ impl TryFrom<RequestActionJsonRepr> for RequestAction {
/// The name of a secret. /// The name of a secret.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub enum SecretName { pub enum SecretName {
/// Cross-signing master key (m.cross_signing.master). /// Cross-signing master key (m.cross_signing.master).

View File

@ -6,7 +6,7 @@ use crate::PrivOwnedStr;
/// The basic key algorithms in the specification. /// The basic key algorithms in the specification.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum DeviceKeyAlgorithm { pub enum DeviceKeyAlgorithm {
@ -25,7 +25,7 @@ pub enum DeviceKeyAlgorithm {
/// The signing key algorithms defined in the Matrix spec. /// The signing key algorithms defined in the Matrix spec.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum SigningKeyAlgorithm { pub enum SigningKeyAlgorithm {
@ -38,7 +38,7 @@ pub enum SigningKeyAlgorithm {
/// An encryption algorithm to be used to encrypt messages sent to a room. /// An encryption algorithm to be used to encrypt messages sent to a room.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum EventEncryptionAlgorithm { pub enum EventEncryptionAlgorithm {
/// Olm version 1 using Curve25519, AES-256, and SHA-256. /// Olm version 1 using Curve25519, AES-256, and SHA-256.
@ -55,7 +55,7 @@ pub enum EventEncryptionAlgorithm {
/// A key algorithm to be used to generate a key from a passphrase. /// A key algorithm to be used to generate a key from a passphrase.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum KeyDerivationAlgorithm { pub enum KeyDerivationAlgorithm {
/// PBKDF2 /// PBKDF2

View File

@ -6,7 +6,7 @@ use crate::{serde::StringEnum, PrivOwnedStr};
/// A description of a user's connectivity and availability for chat. /// A description of a user's connectivity and availability for chat.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, Default, PartialEq, Eq, StringEnum)] #[derive(Clone, Default, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum PresenceState { pub enum PresenceState {

View File

@ -663,7 +663,7 @@ impl HttpPusherData {
/// ///
/// [spec]: https://spec.matrix.org/v1.4/push-gateway-api/#homeserver-behaviour /// [spec]: https://spec.matrix.org/v1.4/push-gateway-api/#homeserver-behaviour
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum PushFormat { pub enum PushFormat {
@ -676,7 +676,7 @@ pub enum PushFormat {
/// The kinds of push rules that are available. /// The kinds of push rules that are available.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum RuleKind { pub enum RuleKind {

View File

@ -21,7 +21,7 @@ pub use room_member_count_is::{ComparisonOperator, RoomMemberCountIs};
/// Features supported by room versions. /// Features supported by room versions.
#[cfg(feature = "unstable-msc3931")] #[cfg(feature = "unstable-msc3931")]
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub enum RoomVersionFeature { pub enum RoomVersionFeature {
/// m.extensible_events /// m.extensible_events

View File

@ -371,7 +371,7 @@ pub enum PredefinedRuleId {
/// The rule IDs of the predefined override server push rules. /// The rule IDs of the predefined override server push rules.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
#[ruma_enum(rename_all = ".m.rule.snake_case")] #[ruma_enum(rename_all = ".m.rule.snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum PredefinedOverrideRuleId { pub enum PredefinedOverrideRuleId {
@ -411,7 +411,7 @@ pub enum PredefinedOverrideRuleId {
/// The rule IDs of the predefined underride server push rules. /// The rule IDs of the predefined underride server push rules.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
#[ruma_enum(rename_all = ".m.rule.snake_case")] #[ruma_enum(rename_all = ".m.rule.snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum PredefinedUnderrideRuleId { pub enum PredefinedUnderrideRuleId {
@ -452,7 +452,7 @@ pub enum PredefinedUnderrideRuleId {
/// The rule IDs of the predefined content server push rules. /// The rule IDs of the predefined content server push rules.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
#[ruma_enum(rename_all = ".m.rule.snake_case")] #[ruma_enum(rename_all = ".m.rule.snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum PredefinedContentRuleId { pub enum PredefinedContentRuleId {

View File

@ -4,7 +4,7 @@ use crate::{serde::StringEnum, PrivOwnedStr};
/// An enum of possible room types. /// An enum of possible room types.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum RoomType { pub enum RoomType {
/// Defines the room as a space. /// Defines the room as a space.

View File

@ -220,7 +220,7 @@ impl User {
/// The medium of a third party identifier. /// The medium of a third party identifier.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "lowercase")] #[ruma_enum(rename_all = "lowercase")]
#[non_exhaustive] #[non_exhaustive]
pub enum Medium { pub enum Medium {

View File

@ -4,7 +4,7 @@ use serde_json::{from_value as from_json_value, json, to_value as to_json_value}
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct PrivOwnedStr(Box<str>); struct PrivOwnedStr(Box<str>);
#[derive(Debug, PartialEq, StringEnum)] #[derive(PartialEq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
enum MyEnum { enum MyEnum {
First, First,
@ -37,6 +37,19 @@ fn display() {
assert_eq!(MyEnum::_Custom(PrivOwnedStr("HelloWorld".into())).to_string(), "HelloWorld"); assert_eq!(MyEnum::_Custom(PrivOwnedStr("HelloWorld".into())).to_string(), "HelloWorld");
} }
#[test]
fn debug() {
assert_eq!(format!("{:?}", MyEnum::First), "\"first\"");
assert_eq!(format!("{:?}", MyEnum::Second), "\"second\"");
assert_eq!(format!("{:?}", MyEnum::Third), "\"m.third\"");
assert_eq!(format!("{:?}", MyEnum::HelloWorld), "\"hello_world\"");
assert_eq!(format!("{:?}", MyEnum::Stable), "\"io.ruma.unstable\"");
assert_eq!(
format!("{:?}", MyEnum::_Custom(PrivOwnedStr("HelloWorld".into()))),
"\"HelloWorld\""
);
}
#[test] #[test]
fn from_string() { fn from_string() {
assert_eq!(MyEnum::from("first"), MyEnum::First); assert_eq!(MyEnum::from("first"), MyEnum::First);

View File

@ -86,7 +86,7 @@ pub mod v1 {
/// string with `::from() / .into()`. To check for values that are not available as a /// string with `::from() / .into()`. To check for values that are not available as a
/// documented variant here, use its string representation, obtained through /// documented variant here, use its string representation, obtained through
/// [`.as_str()`](Self::as_str()). /// [`.as_str()`](Self::as_str()).
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
pub enum ProfileField { pub enum ProfileField {
/// Display name of the user. /// Display name of the user.

View File

@ -13,7 +13,7 @@ pub mod lookup_3pid;
/// This type can hold an arbitrary string. To build this with a custom value, convert it from a /// This type can hold an arbitrary string. To build this with a custom value, convert it from a
/// string with `::from() / .into()`. To check for values that are not available as a documented /// string with `::from() / .into()`. To check for values that are not available as a documented
/// variant here, use its string representation, obtained through [`.as_str()`](Self::as_str()). /// variant here, use its string representation, obtained through [`.as_str()`](Self::as_str()).
#[derive(Debug, PartialEq, Eq, Clone, StringEnum)] #[derive(Clone, PartialEq, Eq, StringEnum)]
#[non_exhaustive] #[non_exhaustive]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum IdentifierHashingAlgorithm { pub enum IdentifierHashingAlgorithm {

View File

@ -338,8 +338,8 @@ pub fn derive_partial_eq_as_ref_str(input: TokenStream) -> TokenStream {
expand_partial_eq_as_ref_str(&input.ident).unwrap_or_else(syn::Error::into_compile_error).into() expand_partial_eq_as_ref_str(&input.ident).unwrap_or_else(syn::Error::into_compile_error).into()
} }
/// Shorthand for the derives `AsRefStr`, `FromString`, `DisplayAsRefStr`, `SerializeAsRefStr` and /// Shorthand for the derives `AsRefStr`, `FromString`, `DisplayAsRefStr`, `DebugAsRefStr`,
/// `DeserializeFromCowStr`. /// `SerializeAsRefStr` and `DeserializeFromCowStr`.
#[proc_macro_derive(StringEnum, attributes(ruma_enum))] #[proc_macro_derive(StringEnum, attributes(ruma_enum))]
pub fn derive_string_enum(input: TokenStream) -> TokenStream { pub fn derive_string_enum(input: TokenStream) -> TokenStream {
fn expand_all(input: ItemEnum) -> syn::Result<proc_macro2::TokenStream> { fn expand_all(input: ItemEnum) -> syn::Result<proc_macro2::TokenStream> {
@ -347,6 +347,7 @@ pub fn derive_string_enum(input: TokenStream) -> TokenStream {
let from_string_impl = expand_enum_from_string(&input)?; let from_string_impl = expand_enum_from_string(&input)?;
let as_str_impl = expand_as_str_as_ref_str(&input.ident)?; let as_str_impl = expand_as_str_as_ref_str(&input.ident)?;
let display_impl = expand_display_as_ref_str(&input.ident)?; let display_impl = expand_display_as_ref_str(&input.ident)?;
let debug_impl = expand_debug_as_ref_str(&input.ident)?;
let serialize_impl = expand_serialize_as_ref_str(&input.ident)?; let serialize_impl = expand_serialize_as_ref_str(&input.ident)?;
let deserialize_impl = expand_deserialize_from_cow_str(&input.ident)?; let deserialize_impl = expand_deserialize_from_cow_str(&input.ident)?;
@ -355,6 +356,7 @@ pub fn derive_string_enum(input: TokenStream) -> TokenStream {
#from_string_impl #from_string_impl
#as_str_impl #as_str_impl
#display_impl #display_impl
#debug_impl
#serialize_impl #serialize_impl
#deserialize_impl #deserialize_impl
}) })

View File

@ -149,7 +149,7 @@ pub mod v1 {
/// This type can hold an arbitrary string. To build this with a custom value, convert it from a /// This type can hold an arbitrary string. To build this with a custom value, convert it from a
/// string with `::from() / .into()`. To check for values that are not available as a /// string with `::from() / .into()`. To check for values that are not available as a
/// documented variant here, use its string representation, obtained through `.as_str()`. /// documented variant here, use its string representation, obtained through `.as_str()`.
#[derive(Clone, Debug, Default, PartialEq, Eq, StringEnum)] #[derive(Clone, Default, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive] #[non_exhaustive]
pub enum NotificationPriority { pub enum NotificationPriority {