events: Make almost all enums non_exhaustive

This commit is contained in:
Jonas Platte 2020-06-13 00:32:44 +02:00
parent 40d3c8ae66
commit 9e04d648ca
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
11 changed files with 18 additions and 0 deletions

View File

@ -32,6 +32,7 @@ pub struct HangupEventContent {
/// 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.
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
#[non_exhaustive]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum Reason {

View File

@ -14,6 +14,7 @@ pub mod start;
/// A hash algorithm.
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Serialize, Deserialize)]
#[non_exhaustive]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum HashAlgorithm {
@ -23,6 +24,7 @@ pub enum HashAlgorithm {
/// A key agreement protocol.
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Serialize, Deserialize)]
#[non_exhaustive]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum KeyAgreementProtocol {
@ -32,6 +34,7 @@ pub enum KeyAgreementProtocol {
/// A message authentication code algorithm.
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Serialize, Deserialize)]
#[non_exhaustive]
#[serde(rename_all = "kebab-case")]
#[strum(serialize_all = "kebab-case")]
pub enum MessageAuthenticationCode {
@ -41,6 +44,7 @@ pub enum MessageAuthenticationCode {
/// A Short Authentication String method.
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Serialize, Deserialize)]
#[non_exhaustive]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum ShortAuthenticationString {
@ -53,6 +57,7 @@ pub enum ShortAuthenticationString {
/// A Short Authentication String (SAS) verification method.
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
#[non_exhaustive]
pub enum VerificationMethod {
/// The *m.sas.v1* verification method.
#[serde(rename = "m.sas.v1")]

View File

@ -32,6 +32,7 @@ pub struct CancelEventContent {
///
/// Custom error codes should use the Java package naming convention.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
#[serde(from = "String", into = "String")]
pub enum CancelCode {
/// The user cancelled the verification.

View File

@ -16,6 +16,7 @@ pub type StartEvent = BasicEvent<StartEventContent>;
/// The payload of an *m.key.verification.start* event.
#[derive(Clone, Debug, Deserialize, Serialize, BasicEventContent)]
#[non_exhaustive]
#[ruma_event(type = "m.key.verification.start")]
#[serde(tag = "method")]
pub enum StartEventContent {

View File

@ -111,6 +111,7 @@ pub struct PatternedPushRule {
/// A condition that must apply for an associated push rule's action to be taken.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[non_exhaustive]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum PushCondition {
/// This is a glob pattern match on a field of the event.

View File

@ -20,6 +20,7 @@ pub struct HistoryVisibilityEventContent {
/// Who can see a room's history.
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
#[non_exhaustive]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum HistoryVisibility {

View File

@ -19,6 +19,7 @@ pub struct JoinRulesEventContent {
/// The rule used for users wishing to join this room.
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
#[non_exhaustive]
#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "lowercase")]
pub enum JoinRule {

View File

@ -64,6 +64,7 @@ pub struct MemberEventContent {
/// The membership state of a user.
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
#[non_exhaustive]
#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "lowercase")]
pub enum MembershipState {
@ -114,6 +115,7 @@ pub struct SignedContent {
/// Translation of the membership change in `m.room.member` event.
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[non_exhaustive]
pub enum MembershipChange {
/// No change.
None,

View File

@ -18,6 +18,7 @@ pub type MessageEvent = OuterMessageEvent<MessageEventContent>;
/// The payload for `MessageEvent`.
#[derive(Clone, Debug, Deserialize, Serialize, MessageEventContent)]
#[non_exhaustive]
#[ruma_event(type = "m.room.message")]
#[serde(tag = "msgtype")]
pub enum MessageEventContent {
@ -248,6 +249,7 @@ pub struct ServerNoticeMessageEventContent {
/// Types of server notices.
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[non_exhaustive]
pub enum ServerNoticeType {
/// The server has exceeded some limit which requires the server administrator to intervene.
#[serde(rename = "m.server_notice.usage_limit_reached")]
@ -256,6 +258,7 @@ pub enum ServerNoticeType {
/// Types of usage limits.
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[non_exhaustive]
#[serde(rename_all = "snake_case")]
pub enum LimitType {
/// The server's number of active users in the last 30 days has exceeded the maximum.

View File

@ -27,6 +27,7 @@ pub struct FeedbackEventContent {
/// A type of feedback.
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
#[non_exhaustive]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum FeedbackType {

View File

@ -37,6 +37,7 @@ pub struct RoomKeyRequestEventContent {
/// A new key request or a cancellation of a previous request.
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
#[non_exhaustive]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum Action {