Merge serde attributes

This commit is contained in:
Jonas Platte 2020-04-03 18:38:16 +02:00
parent cf40608b78
commit abc5b5d446
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
5 changed files with 25 additions and 10 deletions

View File

@ -23,8 +23,11 @@ ruma_api! {
request { request {
/// The time (in milliseconds) to wait when downloading keys from remote servers. /// The time (in milliseconds) to wait when downloading keys from remote servers.
/// 10 seconds is the recommended default. /// 10 seconds is the recommended default.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(
#[serde(default, with = "crate::serde::duration::opt_ms")] with = "crate::serde::duration::opt_ms",
default,
skip_serializing_if = "Option::is_none",
)]
pub timeout: Option<Duration>, pub timeout: Option<Duration>,
/// The keys to be claimed. /// The keys to be claimed.

View File

@ -21,8 +21,11 @@ ruma_api! {
request { request {
/// The time (in milliseconds) to wait when downloading keys from remote servers. /// The time (in milliseconds) to wait when downloading keys from remote servers.
/// 10 seconds is the recommended default. /// 10 seconds is the recommended default.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(
#[serde(default, with = "crate::serde::duration::opt_ms")] with = "crate::serde::duration::opt_ms",
default,
skip_serializing_if = "Option::is_none",
)]
pub timeout: Option<Duration>, pub timeout: Option<Duration>,
/// The keys to be downloaded. An empty list indicates all devices for the corresponding user. /// The keys to be downloaded. An empty list indicates all devices for the corresponding user.

View File

@ -30,8 +30,11 @@ ruma_api! {
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub currently_active: Option<bool>, pub currently_active: Option<bool>,
/// The length of time in milliseconds since an action was performed by the user. /// The length of time in milliseconds since an action was performed by the user.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(
#[serde(default, with = "crate::serde::duration::opt_ms")] with = "crate::serde::duration::opt_ms",
default,
skip_serializing_if = "Option::is_none",
)]
pub last_active_ago: Option<Duration>, pub last_active_ago: Option<Duration>,
/// The user's presence state. /// The user's presence state.
pub presence: PresenceState, pub presence: PresenceState,

View File

@ -20,8 +20,11 @@ ruma_api! {
#[ruma_api(path)] #[ruma_api(path)]
pub room_id: RoomId, pub room_id: RoomId,
/// The length of time in milliseconds to mark this user as typing. /// The length of time in milliseconds to mark this user as typing.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(
#[serde(default, with = "crate::serde::duration::opt_ms")] with = "crate::serde::duration::opt_ms",
default,
skip_serializing_if = "Option::is_none",
)]
pub timeout: Option<Duration>, pub timeout: Option<Duration>,
/// Whether the user is typing or not. If `false`, the `timeout` key can be omitted. /// Whether the user is typing or not. If `false`, the `timeout` key can be omitted.
pub typing: bool, pub typing: bool,

View File

@ -44,8 +44,11 @@ mod tests {
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
struct DurationTest { struct DurationTest {
#[serde(skip_serializing_if = "Option::is_none")] #[serde(
#[serde(default, with = "crate::serde::duration::opt_ms")] with = "crate::serde::duration::opt_ms",
default,
skip_serializing_if = "Option::is_none"
)]
timeout: Option<Duration>, timeout: Option<Duration>,
} }