From 9a8d7bf4759ed3d9bab02c395ff9ab38285ada2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Mon, 20 Jun 2022 19:03:21 +0200 Subject: [PATCH] api: Get the default room version for a Matrix version --- crates/ruma-common/src/api/metadata.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/ruma-common/src/api/metadata.rs b/crates/ruma-common/src/api/metadata.rs index 6be0d5ee..c7f233a8 100644 --- a/crates/ruma-common/src/api/metadata.rs +++ b/crates/ruma-common/src/api/metadata.rs @@ -6,6 +6,7 @@ use std::{ use http::Method; use super::{error::UnknownVersionError, AuthScheme}; +use crate::RoomVersionId; /// Metadata about an API endpoint. #[derive(Clone, Debug)] @@ -228,6 +229,20 @@ impl MatrixVersion { _ => Err(UnknownVersionError), } } + + /// Get the default [`RoomVersionId`] for this `MatrixVersion`. + pub fn default_room_version(&self) -> RoomVersionId { + match self { + // + MatrixVersion::V1_0 + // + | MatrixVersion::V1_1 + // + | MatrixVersion::V1_2 => RoomVersionId::V6, + // + MatrixVersion::V1_3 => RoomVersionId::V9, + } + } } impl Display for MatrixVersion {