identifiers: Declare room versions 7, 8, 9

This commit is contained in:
Jonas Platte 2021-10-02 18:16:19 +02:00
parent 234616c69e
commit cb78a7f341
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
2 changed files with 34 additions and 0 deletions

View File

@ -22,6 +22,7 @@ rustdoc-args = ["--cfg", "docsrs"]
default = ["serde"] default = ["serde"]
compat = ["ruma-identifiers-validation/compat"] compat = ["ruma-identifiers-validation/compat"]
serde = ["ruma-serde", "serde1"] serde = ["ruma-serde", "serde1"]
unstable-pre-spec = []
[dependencies] [dependencies]
either = { version = "1.6.1", optional = true } either = { version = "1.6.1", optional = true }

View File

@ -42,6 +42,21 @@ pub enum RoomVersionId {
/// A version 6 room. /// A version 6 room.
Version6, 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)] #[doc(hidden)]
_Custom(CustomRoomVersion), _Custom(CustomRoomVersion),
} }
@ -58,6 +73,12 @@ impl RoomVersionId {
Self::Version4 => "4", Self::Version4 => "4",
Self::Version5 => "5", Self::Version5 => "5",
Self::Version6 => "6", 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(), Self::_Custom(version) => version.as_str(),
} }
} }
@ -77,6 +98,12 @@ impl From<RoomVersionId> for String {
RoomVersionId::Version4 => "4".to_owned(), RoomVersionId::Version4 => "4".to_owned(),
RoomVersionId::Version5 => "5".to_owned(), RoomVersionId::Version5 => "5".to_owned(),
RoomVersionId::Version6 => "6".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(), RoomVersionId::_Custom(version) => version.into(),
} }
} }
@ -142,6 +169,12 @@ where
"4" => RoomVersionId::Version4, "4" => RoomVersionId::Version4,
"5" => RoomVersionId::Version5, "5" => RoomVersionId::Version5,
"6" => RoomVersionId::Version6, "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 => { custom => {
ruma_identifiers_validation::room_version_id::validate(custom)?; ruma_identifiers_validation::room_version_id::validate(custom)?;
RoomVersionId::_Custom(CustomRoomVersion(room_version_id.into())) RoomVersionId::_Custom(CustomRoomVersion(room_version_id.into()))