From 08dcf1e224f4ab1d5b0ae47071ed99bcbc421aee Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 10 Nov 2022 10:46:38 +0100 Subject: [PATCH] api: Add VersionHistory::{deprecated_in, removed_in} --- crates/ruma-common/src/api/metadata.rs | 10 ++++++++++ crates/ruma-common/tests/api/ui/01-api-sanity-check.rs | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/ruma-common/src/api/metadata.rs b/crates/ruma-common/src/api/metadata.rs index 736a6b0e..756e0904 100644 --- a/crates/ruma-common/src/api/metadata.rs +++ b/crates/ruma-common/src/api/metadata.rs @@ -385,6 +385,16 @@ impl VersionHistory { self.stable_paths.first().map(|(v, _)| *v) } + /// Returns the Matrix version that deprecated this endpoint, if any. + pub fn deprecated_in(&self) -> Option { + self.deprecated + } + + /// Returns the Matrix version that removed this endpoint, if any. + pub fn removed_in(&self) -> Option { + self.removed + } + /// Picks the last unstable path, if it exists. pub fn unstable(&self) -> Option<&'static str> { self.unstable_paths.last().copied() diff --git a/crates/ruma-common/tests/api/ui/01-api-sanity-check.rs b/crates/ruma-common/tests/api/ui/01-api-sanity-check.rs index 6e0cc2d6..0758fb8b 100644 --- a/crates/ruma-common/tests/api/ui/01-api-sanity-check.rs +++ b/crates/ruma-common/tests/api/ui/01-api-sanity-check.rs @@ -74,6 +74,6 @@ fn main() { ); assert_eq!(METADATA.history.added_in(), Some(MatrixVersion::V1_0)); - assert_eq!(METADATA.history.deprecated, Some(MatrixVersion::V1_2)); - assert_eq!(METADATA.history.removed, Some(MatrixVersion::V1_3)); + assert_eq!(METADATA.history.deprecated_in(), Some(MatrixVersion::V1_2)); + assert_eq!(METADATA.history.removed_in(), Some(MatrixVersion::V1_3)); }