Replace serde/strum renames with rename_all

Instead of applying a `#[serde(rename = "foo")]` or `#[strum(serialize =
"foo")]` to each field of a struct or variants of an enum, apply the
appropriate `#[serde(rename_all = "style")]` or `#[strum(serialize_all =
"style")]` to the struct/enum.

In addition, in the places where the `lowercase` style is used and all
the fields/variants are a single word, replace that with `snake_case`,
since that seems to be the default everywhere with multi-word
fields/variants.
This commit is contained in:
Jake Waksbaum 2020-05-29 00:01:14 -04:00
parent d84de004c8
commit e05fdf84fd
No known key found for this signature in database
GPG Key ID: 161DAF1F5CE43352
5 changed files with 16 additions and 22 deletions

View File

@ -24,8 +24,8 @@ pub struct SessionDescription {
/// The type of VoIP session description.
#[derive(Clone, Copy, Debug, Display, EnumString, PartialEq, Deserialize, Serialize)]
#[non_exhaustive]
#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "lowercase")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum SessionDescriptionType {
/// An answer.
Answer,

View File

@ -14,42 +14,40 @@ pub mod start;
/// A hash algorithm.
#[derive(Clone, Copy, Debug, Display, EnumString, Serialize, PartialEq, Deserialize)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum HashAlgorithm {
/// The SHA256 hash algorithm.
#[serde(rename = "sha256")]
#[strum(serialize = "sha256")]
Sha256,
}
/// A key agreement protocol.
#[derive(Clone, Copy, Debug, Display, EnumString, Serialize, PartialEq, Deserialize)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum KeyAgreementProtocol {
/// The [Curve25519](https://cr.yp.to/ecdh.html) key agreement protocol.
#[serde(rename = "curve25519")]
#[strum(serialize = "curve25519")]
Curve25519,
}
/// A message authentication code algorithm.
#[derive(Clone, Copy, Debug, Display, EnumString, Serialize, PartialEq, Deserialize)]
#[serde(rename_all = "kebab-case")]
#[strum(serialize_all = "kebab-case")]
pub enum MessageAuthenticationCode {
/// The HKDF-HMAC-SHA256 MAC.
#[serde(rename = "hkdf-hmac-sha256")]
#[strum(serialize = "hkdf-hmac-sha256")]
HkdfHmacSha256,
}
/// A Short Authentication String method.
#[derive(Clone, Copy, Debug, Display, EnumString, Serialize, PartialEq, Deserialize)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum ShortAuthenticationString {
/// The decimal method.
#[serde(rename = "decimal")]
#[strum(serialize = "decimal")]
Decimal,
/// The emoji method.
#[serde(rename = "emoji")]
#[strum(serialize = "emoji")]
Emoji,
}

View File

@ -44,20 +44,16 @@ ruma_event! {
/// A description of a user's connectivity and availability for chat.
#[derive(Clone, Copy, Debug, Display, EnumString, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum PresenceState {
/// Disconnected from the service.
#[serde(rename = "offline")]
#[strum(serialize = "offline")]
Offline,
/// Connected to the service.
#[serde(rename = "online")]
#[strum(serialize = "online")]
Online,
/// Connected to the service but not available for chat.
#[serde(rename = "unavailable")]
#[strum(serialize = "unavailable")]
Unavailable,
}

View File

@ -26,8 +26,8 @@ ruma_event! {
/// A type of feedback.
#[derive(Clone, Copy, Debug, Display, EnumString, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "lowercase")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum FeedbackType {
/// Sent when a message is received.
Delivered,

View File

@ -37,10 +37,10 @@ ruma_event! {
/// A new key request or a cancellation of a previous request.
#[derive(Clone, Copy, Debug, Display, EnumString, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum Action {
/// Request a key.
#[serde(rename = "request")]
#[strum(serialize = "request")]
Request,
/// Cancel a request for a key.