client-api: Deserialize stable names for unstable features

This commit is contained in:
Kévin Commaille 2022-03-19 12:32:09 +01:00 committed by Kévin Commaille
parent d8617d4dcb
commit 5c2c13145d
6 changed files with 30 additions and 7 deletions

View File

@ -30,7 +30,7 @@ ruma_api! {
/// Information about the tile server to use to display location data. /// Information about the tile server to use to display location data.
#[cfg(feature = "unstable-msc3488")] #[cfg(feature = "unstable-msc3488")]
#[serde(rename = "org.matrix.msc3488.tile_server")] #[serde(rename = "org.matrix.msc3488.tile_server", alias = "m.tile_server")]
pub tile_server: Option<TileServerInfo>, pub tile_server: Option<TileServerInfo>,
} }

View File

@ -67,7 +67,7 @@ pub enum RelationType {
Replacement, Replacement,
/// `m.thread`, a participant to a thread. /// `m.thread`, a participant to a thread.
#[ruma_enum(rename = "io.element.thread")] #[ruma_enum(rename = "io.element.thread", alias = "m.thread")]
Thread, Thread,
#[doc(hidden)] #[doc(hidden)]
@ -153,6 +153,7 @@ pub struct RoomEventFilter<'a> {
#[cfg(feature = "unstable-msc3440")] #[cfg(feature = "unstable-msc3440")]
#[serde( #[serde(
rename = "io.element.relation_types", rename = "io.element.relation_types",
alias = "related_by_rel_types",
default, default,
skip_serializing_if = "<[_]>::is_empty" skip_serializing_if = "<[_]>::is_empty"
)] )]
@ -165,6 +166,7 @@ pub struct RoomEventFilter<'a> {
#[cfg(feature = "unstable-msc3440")] #[cfg(feature = "unstable-msc3440")]
#[serde( #[serde(
rename = "io.element.relation_senders", rename = "io.element.relation_senders",
alias = "related_by_senders",
default, default,
skip_serializing_if = "<[_]>::is_empty" skip_serializing_if = "<[_]>::is_empty"
)] )]

View File

@ -39,7 +39,12 @@ pub mod v3 {
/// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448). /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
#[ruma_api(query)] #[ruma_api(query)]
#[cfg(feature = "unstable-msc2448")] #[cfg(feature = "unstable-msc2448")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default", rename = "xyz.amorgan.blurhash")] #[serde(
default,
skip_serializing_if = "ruma_common::serde::is_default",
rename = "xyz.amorgan.generate_blurhash",
alias = "generate_blurhash"
)]
pub generate_blurhash: bool, pub generate_blurhash: bool,
} }
@ -52,7 +57,11 @@ pub mod v3 {
/// This uses the unstable prefix in /// This uses the unstable prefix in
/// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448). /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
#[cfg(feature = "unstable-msc2448")] #[cfg(feature = "unstable-msc2448")]
#[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")] #[serde(
rename = "xyz.amorgan.blurhash",
alias = "blurhash",
skip_serializing_if = "Option::is_none"
)]
pub blurhash: Option<String>, pub blurhash: Option<String>,
} }

View File

@ -43,7 +43,11 @@ pub mod v3 {
/// This uses the unstable prefix in /// This uses the unstable prefix in
/// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448). /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
#[cfg(feature = "unstable-msc2448")] #[cfg(feature = "unstable-msc2448")]
#[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")] #[serde(
rename = "xyz.amorgan.blurhash",
alias = "blurhash",
skip_serializing_if = "Option::is_none"
)]
pub blurhash: Option<String>, pub blurhash: Option<String>,
} }

View File

@ -47,7 +47,11 @@ pub mod v3 {
/// This uses the unstable prefix in /// This uses the unstable prefix in
/// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448). /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
#[cfg(feature = "unstable-msc2448")] #[cfg(feature = "unstable-msc2448")]
#[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")] #[serde(
rename = "xyz.amorgan.blurhash",
alias = "blurhash",
skip_serializing_if = "Option::is_none"
)]
pub blurhash: Option<String>, pub blurhash: Option<String>,
} }

View File

@ -49,7 +49,11 @@ pub mod v3 {
/// This uses the unstable prefix in /// This uses the unstable prefix in
/// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448). /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
#[cfg(feature = "unstable-msc2448")] #[cfg(feature = "unstable-msc2448")]
#[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")] #[serde(
rename = "xyz.amorgan.blurhash",
alias = "blurhash",
skip_serializing_if = "Option::is_none"
)]
pub blurhash: Option<&'a str>, pub blurhash: Option<&'a str>,
} }