ruma_client_api/keys/upload_signatures/
iter.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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))
    }
}