events: Make all pub enums non_exhaustive
This commit is contained in:
		
							parent
							
								
									74b6a4c9d8
								
							
						
					
					
						commit
						db755f994e
					
				| @ -137,6 +137,7 @@ fn expand_any_with_deser( | ||||
|         #[derive(Clone, Debug, #serde::Serialize)] | ||||
|         #[serde(untagged)] | ||||
|         #[allow(clippy::large_enum_variant)] | ||||
|         #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] | ||||
|         pub enum #ident { | ||||
|             #( | ||||
|                 #[doc = #events] | ||||
| @ -380,6 +381,7 @@ fn expand_content_enum( | ||||
|         #[derive(Clone, Debug, #serde::Serialize)] | ||||
|         #[serde(untagged)] | ||||
|         #[allow(clippy::large_enum_variant)] | ||||
|         #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] | ||||
|         pub enum #ident { | ||||
|             #( | ||||
|                 #[doc = #event_type_str] | ||||
| @ -444,6 +446,7 @@ fn expand_content_enum( | ||||
|             #[derive(Clone, Debug, #serde::Serialize)] | ||||
|             #[serde(untagged)] | ||||
|             #[allow(clippy::large_enum_variant)] | ||||
|             #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] | ||||
|             pub enum #redacted_ident { | ||||
|                 #( | ||||
|                     #[doc = #event_type_str] | ||||
| @ -591,6 +594,7 @@ fn expand_redacted_enum( | ||||
|             /// An enum that holds either regular un-redacted events or redacted events.
 | ||||
|             #[derive(Clone, Debug, #serde::Serialize)] | ||||
|             #[serde(untagged)] | ||||
|             #[allow(clippy::exhaustive_enums)] | ||||
|             pub enum #ident { | ||||
|                 /// An un-redacted event.
 | ||||
|                 Regular(#regular_enum_ident), | ||||
|  | ||||
| @ -128,6 +128,7 @@ fn generate_enum( | ||||
|         /// This type can hold an arbitrary string. To check for events that are not available as a
 | ||||
|         /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
|         #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, #ruma_serde::StringEnum)] | ||||
|         #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] | ||||
|         pub enum #ident { | ||||
|             #( | ||||
|                 #[doc = #ev_type_strings] | ||||
|  | ||||
| @ -30,8 +30,12 @@ impl SessionDescription { | ||||
| } | ||||
| 
 | ||||
| /// The type of VoIP session description.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[ruma_enum(rename_all = "snake_case")] | ||||
| #[non_exhaustive] | ||||
| pub enum SessionDescriptionType { | ||||
|     /// An answer.
 | ||||
|     Answer, | ||||
| @ -42,3 +46,10 @@ pub enum SessionDescriptionType { | ||||
|     #[doc(hidden)] | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl SessionDescriptionType { | ||||
|     /// Creates a string slice from this `SessionDescriptionType`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -39,8 +39,12 @@ impl HangupEventContent { | ||||
| /// 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
 | ||||
| /// `invite_timeout` for when the other party did not answer in time.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[ruma_enum(rename_all = "snake_case")] | ||||
| #[non_exhaustive] | ||||
| pub enum Reason { | ||||
|     /// ICE negotiation failure.
 | ||||
|     IceFailed, | ||||
| @ -51,3 +55,10 @@ pub enum Reason { | ||||
|     #[doc(hidden)] | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl Reason { | ||||
|     /// Creates a string slice from this `Reason`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -139,7 +139,7 @@ macro_rules! room_ev_accessor { | ||||
| } | ||||
| 
 | ||||
| /// Any room event.
 | ||||
| #[allow(clippy::large_enum_variant)] | ||||
| #[allow(clippy::large_enum_variant, clippy::exhaustive_enums)] | ||||
| #[derive(Clone, Debug, Serialize)] | ||||
| #[serde(untagged)] | ||||
| pub enum AnyRoomEvent { | ||||
| @ -164,7 +164,7 @@ impl AnyRoomEvent { | ||||
| } | ||||
| 
 | ||||
| /// Any sync room event (room event without a `room_id`, as returned in `/sync` responses)
 | ||||
| #[allow(clippy::large_enum_variant)] | ||||
| #[allow(clippy::large_enum_variant, clippy::exhaustive_enums)] | ||||
| #[derive(Clone, Debug, Serialize)] | ||||
| #[serde(untagged)] | ||||
| pub enum AnySyncRoomEvent { | ||||
| @ -250,7 +250,7 @@ impl<'de> de::Deserialize<'de> for AnySyncRoomEvent { | ||||
| } | ||||
| 
 | ||||
| /// Any redacted room event.
 | ||||
| #[allow(clippy::large_enum_variant)] | ||||
| #[allow(clippy::large_enum_variant, clippy::exhaustive_enums)] | ||||
| #[derive(Clone, Debug)] | ||||
| pub enum AnyRedactedRoomEvent { | ||||
|     /// Any message event that has been redacted.
 | ||||
| @ -286,7 +286,7 @@ impl From<AnyRedactedRoomEvent> for AnyRoomEvent { | ||||
| } | ||||
| 
 | ||||
| /// Any redacted sync room event (room event without a `room_id`, as returned in `/sync` responses)
 | ||||
| #[allow(clippy::large_enum_variant)] | ||||
| #[allow(clippy::large_enum_variant, clippy::exhaustive_enums)] | ||||
| #[derive(Clone, Debug)] | ||||
| pub enum AnyRedactedSyncRoomEvent { | ||||
|     /// Any sync message event that has been redacted.
 | ||||
|  | ||||
| @ -24,8 +24,12 @@ pub mod request; | ||||
| pub mod start; | ||||
| 
 | ||||
| /// A hash algorithm.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[ruma_enum(rename_all = "snake_case")] | ||||
| #[non_exhaustive] | ||||
| pub enum HashAlgorithm { | ||||
|     /// The SHA256 hash algorithm.
 | ||||
|     Sha256, | ||||
| @ -34,9 +38,20 @@ pub enum HashAlgorithm { | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl HashAlgorithm { | ||||
|     /// Creates a string slice from this `HashAlgorithm`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// A key agreement protocol.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[ruma_enum(rename_all = "kebab-case")] | ||||
| #[non_exhaustive] | ||||
| pub enum KeyAgreementProtocol { | ||||
|     /// The [Curve25519](https://cr.yp.to/ecdh.html) key agreement protocol.
 | ||||
|     Curve25519, | ||||
| @ -48,9 +63,20 @@ pub enum KeyAgreementProtocol { | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl KeyAgreementProtocol { | ||||
|     /// Creates a string slice from this `KeyAgreementProtocol`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// A message authentication code algorithm.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[ruma_enum(rename_all = "kebab-case")] | ||||
| #[non_exhaustive] | ||||
| pub enum MessageAuthenticationCode { | ||||
|     /// The HKDF-HMAC-SHA256 MAC.
 | ||||
|     HkdfHmacSha256, | ||||
| @ -62,9 +88,20 @@ pub enum MessageAuthenticationCode { | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl MessageAuthenticationCode { | ||||
|     /// Creates a string slice from this `MessageAuthenticationCode`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// A Short Authentication String method.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[ruma_enum(rename_all = "snake_case")] | ||||
| #[non_exhaustive] | ||||
| pub enum ShortAuthenticationString { | ||||
|     /// The decimal method.
 | ||||
|     Decimal, | ||||
| @ -76,6 +113,13 @@ pub enum ShortAuthenticationString { | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl ShortAuthenticationString { | ||||
|     /// Creates a string slice from this `ShortAuthenticationString`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// A relation which associates an `m.key.verification.request` with another key verification event.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| #[cfg(feature = "unstable-pre-spec")] | ||||
| @ -96,7 +140,11 @@ impl Relation { | ||||
| } | ||||
| 
 | ||||
| /// A Short Authentication String (SAS) verification method.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[non_exhaustive] | ||||
| pub enum VerificationMethod { | ||||
|     /// The *m.sas.v1* verification method.
 | ||||
|     #[ruma_enum(rename = "m.sas.v1")] | ||||
| @ -121,6 +169,13 @@ pub enum VerificationMethod { | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl VerificationMethod { | ||||
|     /// Creates a string slice from this `VerificationMethod`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #[cfg(test)] | ||||
| mod tests { | ||||
|     use serde_json::{from_value as from_json_value, json}; | ||||
|  | ||||
| @ -75,6 +75,7 @@ impl CancelEventContent { | ||||
| /// obtained through `.as_str()`.
 | ||||
| // FIXME: Add `m.foo_bar` as a naming scheme in StringEnum and remove rename attributes.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[non_exhaustive] | ||||
| pub enum CancelCode { | ||||
|     /// The user cancelled the verification.
 | ||||
|     #[ruma_enum(rename = "m.user")] | ||||
|  | ||||
| @ -418,6 +418,7 @@ pub enum EventKind { | ||||
| /// to aid in deserializing redacted events.
 | ||||
| #[doc(hidden)] | ||||
| #[derive(Debug)] | ||||
| #[allow(clippy::exhaustive_enums)] | ||||
| pub enum HasDeserializeFields { | ||||
|     /// Deserialize the event's content, failing if invalid.
 | ||||
|     True, | ||||
|  | ||||
| @ -29,8 +29,12 @@ impl PolicyRuleEventContent { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// Rules recommendations
 | ||||
| /// The possible actions that can be taken.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[non_exhaustive] | ||||
| pub enum Recommendation { | ||||
|     /// Entities affected by the rule should be banned from participation where possible.
 | ||||
|     #[ruma_enum(rename = "m.ban")] | ||||
|  | ||||
| @ -59,7 +59,11 @@ impl CreateEventContent { | ||||
| } | ||||
| 
 | ||||
| /// An enum of possible room types.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[non_exhaustive] | ||||
| pub enum RoomType { | ||||
|     /// Defines the room as a space.
 | ||||
|     #[ruma_enum(rename = "m.space")] | ||||
| @ -69,6 +73,13 @@ pub enum RoomType { | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl RoomType { | ||||
|     /// Creates a string slice from this `RoomType`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// A reference to an old room replaced during a room version upgrade.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] | ||||
|  | ||||
| @ -29,8 +29,12 @@ impl GuestAccessEventContent { | ||||
| } | ||||
| 
 | ||||
| /// A policy for guest user access to a room.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[ruma_enum(rename_all = "snake_case")] | ||||
| #[non_exhaustive] | ||||
| pub enum GuestAccess { | ||||
|     /// Guests are allowed to join the room.
 | ||||
|     CanJoin, | ||||
| @ -41,3 +45,10 @@ pub enum GuestAccess { | ||||
|     #[doc(hidden)] | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl GuestAccess { | ||||
|     /// Creates a string slice from this `GuestAccess`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -28,8 +28,12 @@ impl HistoryVisibilityEventContent { | ||||
| } | ||||
| 
 | ||||
| /// Who can see a room's history.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[ruma_enum(rename_all = "snake_case")] | ||||
| #[non_exhaustive] | ||||
| pub enum HistoryVisibility { | ||||
|     /// Previous events are accessible to newly joined members from the point they were invited
 | ||||
|     /// onwards. Events stop being accessible when the member's state changes to something other
 | ||||
| @ -52,3 +56,10 @@ pub enum HistoryVisibility { | ||||
|     #[doc(hidden)] | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl HistoryVisibility { | ||||
|     /// Creates a string slice from this `HistoryVisibility`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -27,8 +27,12 @@ impl JoinRulesEventContent { | ||||
| } | ||||
| 
 | ||||
| /// The rule used for users wishing to join this room.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[ruma_enum(rename_all = "lowercase")] | ||||
| #[non_exhaustive] | ||||
| pub enum JoinRule { | ||||
|     /// A user who wishes to join the room must first receive an invite to the room from someone
 | ||||
|     /// already inside of the room.
 | ||||
| @ -46,3 +50,10 @@ pub enum JoinRule { | ||||
|     #[doc(hidden)] | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl JoinRule { | ||||
|     /// Creates a string slice from this `JoinRule`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -105,8 +105,12 @@ impl MemberEventContent { | ||||
| } | ||||
| 
 | ||||
| /// The membership state of a user.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[ruma_enum(rename_all = "lowercase")] | ||||
| #[non_exhaustive] | ||||
| pub enum MembershipState { | ||||
|     /// The user is banned.
 | ||||
|     Ban, | ||||
| @ -127,6 +131,13 @@ pub enum MembershipState { | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl MembershipState { | ||||
|     /// Creates a string slice from this `MembershipState`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// Information about a third party invitation.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] | ||||
|  | ||||
| @ -142,6 +142,7 @@ impl MessageEventContent { | ||||
| /// The content that is specific to each message type variant.
 | ||||
| #[derive(Clone, Debug, Serialize)] | ||||
| #[serde(untagged)] | ||||
| #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] | ||||
| pub enum MessageType { | ||||
|     /// An audio message.
 | ||||
|     Audio(AudioMessageEventContent), | ||||
| @ -647,7 +648,11 @@ impl ServerNoticeMessageEventContent { | ||||
| } | ||||
| 
 | ||||
| /// Types of server notices.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[non_exhaustive] | ||||
| pub enum ServerNoticeType { | ||||
|     /// The server has exceeded some limit which requires the server administrator to intervene.
 | ||||
|     #[ruma_enum(rename = "m.server_notice.usage_limit_reached")] | ||||
| @ -657,9 +662,20 @@ pub enum ServerNoticeType { | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl ServerNoticeType { | ||||
|     /// Creates a string slice from this `ServerNoticeType`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// Types of usage limits.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[ruma_enum(rename_all = "snake_case")] | ||||
| #[non_exhaustive] | ||||
| pub enum LimitType { | ||||
|     /// The server's number of active users in the last 30 days has exceeded the maximum.
 | ||||
|     ///
 | ||||
| @ -671,11 +687,19 @@ pub enum LimitType { | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl LimitType { | ||||
|     /// Creates a string slice from this `LimitType`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// The format for the formatted representation of a message body.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[non_exhaustive] | ||||
| pub enum MessageFormat { | ||||
|     /// HTML.
 | ||||
|     #[ruma_enum(rename = "org.matrix.custom.html")] | ||||
|  | ||||
| @ -34,8 +34,12 @@ impl FeedbackEventContent { | ||||
| } | ||||
| 
 | ||||
| /// A type of feedback.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[ruma_enum(rename_all = "snake_case")] | ||||
| #[non_exhaustive] | ||||
| pub enum FeedbackType { | ||||
|     /// Sent when a message is received.
 | ||||
|     Delivered, | ||||
| @ -46,3 +50,10 @@ pub enum FeedbackType { | ||||
|     #[doc(hidden)] | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl FeedbackType { | ||||
|     /// Creates a string slice from this `FeedbackType`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -42,8 +42,12 @@ impl RoomKeyRequestToDeviceEventContent { | ||||
| } | ||||
| 
 | ||||
| /// A new key request or a cancellation of a previous request.
 | ||||
| ///
 | ||||
| /// This type can hold an arbitrary string. To check for formats that are not available as a
 | ||||
| /// documented variant here, use its string representation, obtained through `.as_str()`.
 | ||||
| #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] | ||||
| #[ruma_enum(rename_all = "snake_case")] | ||||
| #[non_exhaustive] | ||||
| pub enum Action { | ||||
|     /// Request a key.
 | ||||
|     Request, | ||||
| @ -56,6 +60,13 @@ pub enum Action { | ||||
|     _Custom(String), | ||||
| } | ||||
| 
 | ||||
| impl Action { | ||||
|     /// Creates a string slice from this `Action`.
 | ||||
|     pub fn as_str(&self) -> &str { | ||||
|         self.as_ref() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// Information about a requested key.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user