Derive PartialEq and Eq for all string-wrapping enums

This commit is contained in:
Jonas Platte 2020-11-01 14:41:31 +01:00
parent d34a270919
commit dd6446822b
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
20 changed files with 27 additions and 27 deletions

View File

@ -61,7 +61,7 @@ impl Response {
} }
/// Access token types. /// Access token types.
#[derive(Clone, Debug, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
pub enum TokenType { pub enum TokenType {
/// Bearer token type /// Bearer token type
Bearer, Bearer,

View File

@ -63,7 +63,7 @@ impl Response {
} }
/// The kind of membership events to filter for. /// The kind of membership events to filter for.
#[derive(Clone, Debug, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "lowercase")] #[ruma_enum(rename_all = "lowercase")]
pub enum MembershipEventFilter { pub enum MembershipEventFilter {
/// The user has joined. /// The user has joined.

View File

@ -70,7 +70,7 @@ pub struct Pusher {
} }
/// Which kind a pusher is /// Which kind a pusher is
#[derive(Clone, Debug, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum PusherKind { pub enum PusherKind {
/// A pusher that sends HTTP pokes. /// A pusher that sends HTTP pokes.

View File

@ -160,7 +160,7 @@ impl Default for CreationContent {
} }
/// A convenience parameter for setting a few default state events. /// A convenience parameter for setting a few default state events.
#[derive(Clone, Debug, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum RoomPreset { pub enum RoomPreset {
/// `join_rules` is set to `invite` and `history_visibility` is set to `shared`. /// `join_rules` is set to `invite` and `history_visibility` is set to `shared`.

View File

@ -272,7 +272,7 @@ impl Groupings<'_> {
} }
/// The keys to search for. /// The keys to search for.
#[derive(Clone, Debug, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
pub enum SearchKeys { pub enum SearchKeys {
/// content.body /// content.body
#[ruma_enum(rename = "content.body")] #[ruma_enum(rename = "content.body")]
@ -291,7 +291,7 @@ pub enum SearchKeys {
} }
/// The order in which to search for results. /// The order in which to search for results.
#[derive(Clone, Debug, StringEnum)] #[derive(Clone, Debug, 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

@ -5,7 +5,7 @@
use crate::StringEnum; use crate::StringEnum;
/// A description of a user's connectivity and availability for chat. /// A description of a user's connectivity and availability for chat.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum PresenceState { pub enum PresenceState {
/// Disconnected from the service. /// Disconnected from the service.

View File

@ -238,7 +238,7 @@ impl PusherData {
/// Currently, only "event_id_only" is supported as of [Push Gateway API r0.1.1][spec]. /// Currently, only "event_id_only" is supported as of [Push Gateway API r0.1.1][spec].
/// ///
/// [spec]: https://matrix.org/docs/spec/push_gateway/r0.1.1#homeserver-behaviour /// [spec]: https://matrix.org/docs/spec/push_gateway/r0.1.1#homeserver-behaviour
#[derive(Clone, Debug, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum PushFormat { pub enum PushFormat {
/// Require the homeserver to only send a reduced set of fields in the push. /// Require the homeserver to only send a reduced set of fields in the push.

View File

@ -30,7 +30,7 @@ impl SessionDescription {
} }
/// The type of VoIP session description. /// The type of VoIP session description.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum SessionDescriptionType { pub enum SessionDescriptionType {
/// An answer. /// An answer.

View File

@ -31,7 +31,7 @@ pub struct HangupEventContent {
/// This should not be provided when the user naturally ends or rejects the call. When there was an /// This should not be provided when the user naturally ends or rejects the call. When there was an
/// error in the call negotiation, this should be `ice_failed` for when ICE negotiation fails or /// error 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.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum Reason { pub enum Reason {
/// ICE negotiation failure. /// ICE negotiation failure.

View File

@ -12,7 +12,7 @@ pub mod request;
pub mod start; pub mod start;
/// A hash algorithm. /// A hash algorithm.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum HashAlgorithm { pub enum HashAlgorithm {
/// The SHA256 hash algorithm. /// The SHA256 hash algorithm.
@ -23,7 +23,7 @@ pub enum HashAlgorithm {
} }
/// A key agreement protocol. /// A key agreement protocol.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "kebab-case")] #[ruma_enum(rename_all = "kebab-case")]
pub enum KeyAgreementProtocol { pub enum KeyAgreementProtocol {
/// The [Curve25519](https://cr.yp.to/ecdh.html) key agreement protocol. /// The [Curve25519](https://cr.yp.to/ecdh.html) key agreement protocol.
@ -37,7 +37,7 @@ pub enum KeyAgreementProtocol {
} }
/// A message authentication code algorithm. /// A message authentication code algorithm.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "kebab-case")] #[ruma_enum(rename_all = "kebab-case")]
pub enum MessageAuthenticationCode { pub enum MessageAuthenticationCode {
/// The HKDF-HMAC-SHA256 MAC. /// The HKDF-HMAC-SHA256 MAC.
@ -51,7 +51,7 @@ pub enum MessageAuthenticationCode {
} }
/// A Short Authentication String method. /// A Short Authentication String method.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum ShortAuthenticationString { pub enum ShortAuthenticationString {
/// The decimal method. /// The decimal method.
@ -65,7 +65,7 @@ pub enum ShortAuthenticationString {
} }
/// A Short Authentication String (SAS) verification method. /// A Short Authentication String (SAS) verification method.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
pub enum VerificationMethod { pub enum VerificationMethod {
/// The *m.sas.v1* verification method. /// The *m.sas.v1* verification method.
#[ruma_enum(rename = "m.sas.v1")] #[ruma_enum(rename = "m.sas.v1")]

View File

@ -35,7 +35,7 @@ pub struct CancelEventContent {
/// available as a documented variant here, use its string representation, /// available as a documented variant here, use its string representation,
/// obtained through `.as_str()`. /// obtained through `.as_str()`.
// 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, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
pub enum CancelCode { pub enum CancelCode {
/// The user cancelled the verification. /// The user cancelled the verification.
#[ruma_enum(rename = "m.user")] #[ruma_enum(rename = "m.user")]

View File

@ -29,7 +29,7 @@ impl PolicyRuleEventContent {
} }
/// Rules recommendations /// Rules recommendations
#[derive(Clone, Debug, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
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.
#[ruma_enum(rename = "m.ban")] #[ruma_enum(rename = "m.ban")]

View File

@ -29,7 +29,7 @@ impl GuestAccessEventContent {
} }
/// A policy for guest user access to a room. /// A policy for guest user access to a room.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum GuestAccess { pub enum GuestAccess {
/// Guests are allowed to join the room. /// Guests are allowed to join the room.

View File

@ -28,7 +28,7 @@ impl HistoryVisibilityEventContent {
} }
/// Who can see a room's history. /// Who can see a room's history.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum HistoryVisibility { pub enum HistoryVisibility {
/// Previous events are accessible to newly joined members from the point they were invited /// Previous events are accessible to newly joined members from the point they were invited

View File

@ -27,7 +27,7 @@ impl JoinRulesEventContent {
} }
/// The rule used for users wishing to join this room. /// The rule used for users wishing to join this room.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "lowercase")] #[ruma_enum(rename_all = "lowercase")]
pub enum JoinRule { pub enum JoinRule {
/// A user who wishes to join the room must first receive an invite to the room from someone /// A user who wishes to join the room must first receive an invite to the room from someone

View File

@ -64,7 +64,7 @@ pub struct MemberEventContent {
} }
/// The membership state of a user. /// The membership state of a user.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "lowercase")] #[ruma_enum(rename_all = "lowercase")]
pub enum MembershipState { pub enum MembershipState {
/// The user is banned. /// The user is banned.

View File

@ -287,7 +287,7 @@ pub struct ServerNoticeMessageEventContent {
} }
/// Types of server notices. /// Types of server notices.
#[derive(Clone, Debug, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
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.
#[ruma_enum(rename = "m.server_notice.usage_limit_reached")] #[ruma_enum(rename = "m.server_notice.usage_limit_reached")]
@ -298,7 +298,7 @@ pub enum ServerNoticeType {
} }
/// Types of usage limits. /// Types of usage limits.
#[derive(Clone, Debug, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum LimitType { pub enum LimitType {
/// The server's number of active users in the last 30 days has exceeded the maximum. /// The server's number of active users in the last 30 days has exceeded the maximum.
@ -316,7 +316,7 @@ pub enum LimitType {
/// This type can hold an arbitrary string. To check for events that are not /// This type can hold an arbitrary string. To check for events that are not
/// available as a documented variant here, use its string representation, /// available as a documented variant here, use its string representation,
/// obtained through `.as_str()`. /// obtained through `.as_str()`.
#[derive(Clone, Debug, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
pub enum MessageFormat { pub enum MessageFormat {
/// HTML. /// HTML.
#[ruma_enum(rename = "org.matrix.custom.html")] #[ruma_enum(rename = "org.matrix.custom.html")]

View File

@ -34,7 +34,7 @@ impl FeedbackEventContent {
} }
/// A type of feedback. /// A type of feedback.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum FeedbackType { pub enum FeedbackType {
/// Sent when a message is received. /// Sent when a message is received.

View File

@ -35,7 +35,7 @@ pub struct RoomKeyRequestEventContent {
} }
/// A new key request or a cancellation of a previous request. /// A new key request or a cancellation of a previous request.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum Action { pub enum Action {
/// Request a key. /// Request a key.

View File

@ -136,7 +136,7 @@ impl<'a> Notification<'a> {
/// ///
/// This may be used by push gateways to deliver less time-sensitive /// This may be used by push gateways to deliver less time-sensitive
/// notifications in a way that will preserve battery power on mobile devices. /// notifications in a way that will preserve battery power on mobile devices.
#[derive(Clone, Debug, PartialEq, StringEnum)] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")] #[ruma_enum(rename_all = "snake_case")]
pub enum NotificationPriority { pub enum NotificationPriority {
/// A high priority notification /// A high priority notification