mirror of
https://github.com/girlbossceo/ruwuma.git
synced 2025-04-29 06:49:48 -04:00
identity-service-api: Return a BTreeSet for get_supported_versions::Response::known_versions()
This commit is contained in:
parent
990d01b19d
commit
0533699453
2 changed files with 22 additions and 9 deletions
|
@ -1,5 +1,23 @@
|
|||
# [unreleased]
|
||||
|
||||
=======
|
||||
Breaking changes:
|
||||
|
||||
- `get_supported_versions::Response::known_versions()` returns a
|
||||
`BTreeSet<MatrixVersion>` instead of a `DoubleEndedIterator`.
|
||||
|
||||
# 0.11.0
|
||||
|
||||
Improvements:
|
||||
|
||||
- The `unstable-exhaustive-types` cargo feature was replaced by the
|
||||
`ruma_unstable_exhaustive_types` compile-time `cfg` setting. Like all `cfg`
|
||||
settings, it can be enabled at compile-time with the `RUSTFLAGS` environment
|
||||
variable, or inside `.cargo/config.toml`. It can also be enabled by setting
|
||||
the `RUMA_UNSTABLE_EXHAUSTIVE_TYPES` environment variable.
|
||||
|
||||
# 0.10.0
|
||||
|
||||
Breaking changes:
|
||||
|
||||
- Change type of `client_secret` field in `ThreePidOwnershipProof`
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
//!
|
||||
//! [spec]: https://spec.matrix.org/latest/identity-service-api/#get_matrixidentityversions
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, MatrixVersion, Metadata},
|
||||
|
@ -58,17 +58,12 @@ impl Response {
|
|||
/// The versions returned will be sorted from oldest to latest. Use [`.find()`][Iterator::find]
|
||||
/// or [`.rfind()`][DoubleEndedIterator::rfind] to look for a minimum or maximum version to use
|
||||
/// given some constraint.
|
||||
pub fn known_versions(&self) -> impl DoubleEndedIterator<Item = MatrixVersion> {
|
||||
pub fn known_versions(&self) -> BTreeSet<MatrixVersion> {
|
||||
self.versions
|
||||
.iter()
|
||||
// Parse, discard unknown versions
|
||||
.flat_map(|s| s.parse::<MatrixVersion>())
|
||||
// Map to key-value pairs where the key is the major-minor representation
|
||||
// (which can be used as a BTreeMap unlike MatrixVersion itself)
|
||||
.map(|v| (v.into_parts(), v))
|
||||
// Collect to BTreeMap
|
||||
.collect::<BTreeMap<_, _>>()
|
||||
// Return an iterator over just the values (`MatrixVersion`s)
|
||||
.into_values()
|
||||
// Collect to BTreeSet
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue