api: Add VersionHistory::{deprecated_in, removed_in}

This commit is contained in:
Jonas Platte 2022-11-10 10:46:38 +01:00
parent 866b01d0c2
commit 08dcf1e224
No known key found for this signature in database
GPG Key ID: AAA7A61F696C3E0C
2 changed files with 12 additions and 2 deletions

View File

@ -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<MatrixVersion> {
self.deprecated
}
/// Returns the Matrix version that removed this endpoint, if any.
pub fn removed_in(&self) -> Option<MatrixVersion> {
self.removed
}
/// Picks the last unstable path, if it exists.
pub fn unstable(&self) -> Option<&'static str> {
self.unstable_paths.last().copied()

View File

@ -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));
}