xmpp-parsers: Make DiscoInfoResult::features a BTreeSet
Features must never be duplicated, so we can use a BTreeSet instead of a Vec to be nicer for users. It makes the internal API for computing caps and ecaps2 a bit worse, because it was expecting a slice directly, so for now let’s collect the BTreeSet into a Vec when computing the thing. A refactor to use Iterator might make it better eventually, but I won’t work on that before profiling it.
This commit is contained in:
parent
946d96d7c8
commit
bc88134c41
6 changed files with 20 additions and 9 deletions
|
|
@ -124,7 +124,10 @@ fn compute_extensions(extensions: &[DataForm]) -> Result<Vec<u8>, Error> {
|
|||
/// XEP-0390](https://xmpp.org/extensions/xep-0390.html#algorithm-input) on a
|
||||
/// [disco#info query element](../disco/struct.DiscoInfoResult.html).
|
||||
pub fn compute_disco(disco: &DiscoInfoResult) -> Result<Vec<u8>, Error> {
|
||||
let features_string = compute_features(&disco.features);
|
||||
// TODO: Figure out a way to remove the clones here.
|
||||
let features: Vec<_> = disco.features.iter().cloned().collect();
|
||||
|
||||
let features_string = compute_features(&features);
|
||||
let identities_string = compute_identities(&disco.identities);
|
||||
let extensions_string = compute_extensions(&disco.extensions)?;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue