client-api: Add a borrowing iterator for SignedKeys
This commit is contained in:
parent
b3d4b27b91
commit
fa2e3662a4
@ -16,6 +16,8 @@ pub mod v3 {
|
|||||||
|
|
||||||
use crate::PrivOwnedStr;
|
use crate::PrivOwnedStr;
|
||||||
|
|
||||||
|
pub use super::iter::SignedKeysIter;
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
description: "Publishes cross-signing signatures for the user.",
|
description: "Publishes cross-signing signatures for the user.",
|
||||||
@ -81,6 +83,11 @@ pub mod v3 {
|
|||||||
) {
|
) {
|
||||||
self.0.insert(cross_signing_key_id, cross_signing_keys.into_json());
|
self.0.insert(cross_signing_key_id, cross_signing_keys.into_json());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns an iterator over the keys.
|
||||||
|
pub fn iter(&self) -> SignedKeysIter<'_> {
|
||||||
|
SignedKeysIter(self.0.iter())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A failure to process a signed key.
|
/// A failure to process a signed key.
|
||||||
@ -105,3 +112,5 @@ pub mod v3 {
|
|||||||
_Custom(PrivOwnedStr),
|
_Custom(PrivOwnedStr),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod iter;
|
||||||
|
26
crates/ruma-client-api/src/keys/upload_signatures/iter.rs
Normal file
26
crates/ruma-client-api/src/keys/upload_signatures/iter.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
use std::collections::btree_map;
|
||||||
|
|
||||||
|
use serde_json::value::RawValue as RawJsonValue;
|
||||||
|
|
||||||
|
use super::v3::SignedKeys;
|
||||||
|
|
||||||
|
impl<'a> IntoIterator for &'a SignedKeys {
|
||||||
|
type Item = (&'a str, &'a RawJsonValue);
|
||||||
|
type IntoIter = SignedKeysIter<'a>;
|
||||||
|
|
||||||
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
|
self.iter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An iterator over signed key IDs and their associated data.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct SignedKeysIter<'a>(pub(super) btree_map::Iter<'a, Box<str>, Box<RawJsonValue>>);
|
||||||
|
|
||||||
|
impl<'a> Iterator for SignedKeysIter<'a> {
|
||||||
|
type Item = (&'a str, &'a RawJsonValue);
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
self.0.next().map(|(id, val)| (&**id, &**val))
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user