From cb78a7f3416960fdf0fe8348235665e4791fd4cd Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Sat, 2 Oct 2021 18:16:19 +0200 Subject: [PATCH] identifiers: Declare room versions 7, 8, 9 --- crates/ruma-identifiers/Cargo.toml | 1 + .../ruma-identifiers/src/room_version_id.rs | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/crates/ruma-identifiers/Cargo.toml b/crates/ruma-identifiers/Cargo.toml index 0ba8a0a7..7a6cbd55 100644 --- a/crates/ruma-identifiers/Cargo.toml +++ b/crates/ruma-identifiers/Cargo.toml @@ -22,6 +22,7 @@ rustdoc-args = ["--cfg", "docsrs"] default = ["serde"] compat = ["ruma-identifiers-validation/compat"] serde = ["ruma-serde", "serde1"] +unstable-pre-spec = [] [dependencies] either = { version = "1.6.1", optional = true } diff --git a/crates/ruma-identifiers/src/room_version_id.rs b/crates/ruma-identifiers/src/room_version_id.rs index f4344415..40e4270e 100644 --- a/crates/ruma-identifiers/src/room_version_id.rs +++ b/crates/ruma-identifiers/src/room_version_id.rs @@ -42,6 +42,21 @@ pub enum RoomVersionId { /// A version 6 room. Version6, + /// A version 7 room. + #[cfg(feature = "unstable-pre-spec")] + #[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] + Version7, + + /// A version 8 room. + #[cfg(feature = "unstable-pre-spec")] + #[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] + Version8, + + /// A version 9 room. + #[cfg(feature = "unstable-pre-spec")] + #[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] + Version9, + #[doc(hidden)] _Custom(CustomRoomVersion), } @@ -58,6 +73,12 @@ impl RoomVersionId { Self::Version4 => "4", Self::Version5 => "5", Self::Version6 => "6", + #[cfg(feature = "unstable-pre-spec")] + Self::Version7 => "7", + #[cfg(feature = "unstable-pre-spec")] + Self::Version8 => "8", + #[cfg(feature = "unstable-pre-spec")] + Self::Version9 => "9", Self::_Custom(version) => version.as_str(), } } @@ -77,6 +98,12 @@ impl From for String { RoomVersionId::Version4 => "4".to_owned(), RoomVersionId::Version5 => "5".to_owned(), RoomVersionId::Version6 => "6".to_owned(), + #[cfg(feature = "unstable-pre-spec")] + RoomVersionId::Version7 => "7".to_owned(), + #[cfg(feature = "unstable-pre-spec")] + RoomVersionId::Version8 => "8".to_owned(), + #[cfg(feature = "unstable-pre-spec")] + RoomVersionId::Version9 => "9".to_owned(), RoomVersionId::_Custom(version) => version.into(), } } @@ -142,6 +169,12 @@ where "4" => RoomVersionId::Version4, "5" => RoomVersionId::Version5, "6" => RoomVersionId::Version6, + #[cfg(feature = "unstable-pre-spec")] + "7" => RoomVersionId::Version7, + #[cfg(feature = "unstable-pre-spec")] + "8" => RoomVersionId::Version8, + #[cfg(feature = "unstable-pre-spec")] + "9" => RoomVersionId::Version9, custom => { ruma_identifiers_validation::room_version_id::validate(custom)?; RoomVersionId::_Custom(CustomRoomVersion(room_version_id.into()))