diff --git a/src/r0/account/register.rs b/src/r0/account/register.rs index a83da7cc..64c71d66 100644 --- a/src/r0/account/register.rs +++ b/src/r0/account/register.rs @@ -85,13 +85,12 @@ pub struct AuthenticationData { /// The kind of account being registered. #[derive(Copy, Clone, Debug, Deserialize, Serialize)] +#[serde(rename_all = "snake_case")] pub enum RegistrationKind { /// A guest account /// /// These accounts may have limited permissions and may not be supported by all servers. - #[serde(rename = "guest")] Guest, /// A regular user account - #[serde(rename = "user")] User, } diff --git a/src/r0/filter.rs b/src/r0/filter.rs index 952c7165..5dd3a579 100644 --- a/src/r0/filter.rs +++ b/src/r0/filter.rs @@ -9,12 +9,11 @@ use serde::{Deserialize, Serialize}; /// Format to use for returned events #[derive(Copy, Clone, Debug, Deserialize, Serialize)] +#[serde(rename_all = "snake_case")] pub enum EventFormat { /// Client format, as described in the Client API. - #[serde(rename = "client")] Client, /// Raw events from federation. - #[serde(rename = "federation")] Federation, } @@ -26,15 +25,13 @@ pub struct RoomEventFilter { /// If this list is absent then no event types are excluded. A matching type will be excluded /// even if it is listed in the 'types' filter. A '*' can be used as a wildcard to match any /// sequence of characters. - #[serde(skip_serializing_if = "Vec::is_empty")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub not_types: Vec, /// A list of room IDs to exclude. /// /// If this list is absent then no rooms are excluded. A matching room will be excluded even if /// it is listed in the 'rooms' filter. - #[serde(skip_serializing_if = "Vec::is_empty")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub not_rooms: Vec, /// The maximum number of events to return. #[serde(skip_serializing_if = "Option::is_none")] @@ -42,28 +39,24 @@ pub struct RoomEventFilter { /// A list of room IDs to include. /// /// If this list is absent then all rooms are included. - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Option::is_none")] pub rooms: Option>, /// A list of sender IDs to exclude. /// /// If this list is absent then no senders are excluded. A matching sender will be excluded even /// if it is listed in the 'senders' filter. - #[serde(skip_serializing_if = "Vec::is_empty")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub not_senders: Vec, /// A list of senders IDs to include. /// /// If this list is absent then all senders are included. - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Option::is_none")] pub senders: Option>, /// A list of event types to include. /// /// If this list is absent then all event types are included. A '*' can be used as a wildcard to /// match any sequence of characters. - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Option::is_none")] pub types: Option>, } @@ -93,15 +86,13 @@ pub struct RoomFilter { /// If this list is absent then no rooms are excluded. A matching room will be excluded even if /// it is listed in the 'rooms' filter. This filter is applied before the filters in /// `ephemeral`, `state`, `timeline` or `account_data`. - #[serde(skip_serializing_if = "Vec::is_empty")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub not_rooms: Vec, /// A list of room IDs to include. /// /// If this list is absent then all rooms are included. This filter is applied before the /// filters in `ephemeral`, `state`, `timeline` or `account_data`. - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Option::is_none")] pub rooms: Option>, } @@ -113,8 +104,7 @@ pub struct Filter { /// If this list is absent then no event types are excluded. A matching type will be excluded /// even if it is listed in the 'types' filter. A '*' can be used as a wildcard to match any /// sequence of characters. - #[serde(skip_serializing_if = "Vec::is_empty")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub not_types: Vec, /// The maximum number of events to return. #[serde(skip_serializing_if = "Option::is_none")] @@ -122,22 +112,19 @@ pub struct Filter { /// A list of senders IDs to include. /// /// If this list is absent then all senders are included. - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Option::is_none")] pub senders: Option>, /// A list of event types to include. /// /// If this list is absent then all event types are included. A '*' can be used as a wildcard to /// match any sequence of characters. - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Option::is_none")] pub types: Option>, /// A list of sender IDs to exclude. /// /// If this list is absent then no senders are excluded. A matching sender will be excluded even /// if it is listed in the 'senders' filter. - #[serde(skip_serializing_if = "Vec::is_empty")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub not_senders: Vec, } @@ -150,8 +137,7 @@ pub struct FilterDefinition { /// to indicate sub-fields. So ['content.body'] will include the 'body' field of the 'content' /// object. A literal '.' character in a field name may be escaped using a '\'. A server may /// include more fields than were requested. - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Option::is_none")] pub event_fields: Option>, /// The format to use for events. /// diff --git a/src/r0/media/get_content_thumbnail.rs b/src/r0/media/get_content_thumbnail.rs index 82bea3d4..5090b419 100644 --- a/src/r0/media/get_content_thumbnail.rs +++ b/src/r0/media/get_content_thumbnail.rs @@ -6,12 +6,11 @@ use serde::{Deserialize, Serialize}; /// The desired resizing method. #[derive(Clone, Copy, Debug, Deserialize, Serialize)] +#[serde(rename_all = "snake_case")] pub enum Method { /// Crop the original to produce the requested image dimensions. - #[serde(rename = "crop")] Crop, /// Maintain the original aspect ratio of the source image. - #[serde(rename = "scale")] Scale, } diff --git a/src/r0/presence/update_presence_subscriptions.rs b/src/r0/presence/update_presence_subscriptions.rs index 7832967c..bf957425 100644 --- a/src/r0/presence/update_presence_subscriptions.rs +++ b/src/r0/presence/update_presence_subscriptions.rs @@ -15,12 +15,10 @@ ruma_api! { request { /// A list of user IDs to remove from the list. - #[serde(skip_serializing_if = "Vec::is_empty")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub drop: Vec, /// A list of user IDs to add to the list. - #[serde(skip_serializing_if = "Vec::is_empty")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub invite: Vec, /// The user whose presence state will be updated. #[ruma_api(path)] diff --git a/src/r0/room/create_room.rs b/src/r0/room/create_room.rs index 09de202a..21b40d80 100644 --- a/src/r0/room/create_room.rs +++ b/src/r0/room/create_room.rs @@ -21,8 +21,7 @@ ruma_api! { /// A list of user IDs to invite to the room. /// /// This will tell the server to invite everyone in the list to the newly created room. - #[serde(skip_serializing_if = "Vec::is_empty")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub invite: Vec, /// If this is included, an `m.room.name` event will be sent into the room to indicate /// the name of the room. diff --git a/src/r0/search/search_events.rs b/src/r0/search/search_events.rs index e9d67459..c235dee4 100644 --- a/src/r0/search/search_events.rs +++ b/src/r0/search/search_events.rs @@ -62,8 +62,7 @@ pub struct Criteria { #[serde(skip_serializing_if = "Option::is_none")] pub include_state: Option, /// The keys to search for. Defaults to all keys. - #[serde(skip_serializing_if = "Vec::is_empty")] - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub keys: Vec, /// The order in which to search for results. #[serde(skip_serializing_if = "Option::is_none")] @@ -112,12 +111,11 @@ pub struct Grouping { /// The key within events to use for this grouping. #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +#[serde(rename_all = "snake_case")] pub enum GroupingKey { /// `room_id` - #[serde(rename = "room_id")] RoomId, /// `sender` - #[serde(rename = "sender")] Sender, } @@ -144,13 +142,12 @@ pub enum SearchKeys { /// The order in which to search for results. #[derive(Clone, Copy, Debug, Deserialize, Serialize)] +#[serde(rename_all = "snake_case")] pub enum OrderBy { /// Prioritize events by a numerical ranking of how closely they matched the search /// criteria. - #[serde(rename = "rank")] Rank, /// Prioritize recent events. - #[serde(rename = "recent")] Recent, }