matrix_sdk_crypto/types/requests/keys_query.rs
1// Copyright 2020 The Matrix.org Foundation C.I.C.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::{collections::BTreeMap, time::Duration};
16
17use ruma::{OwnedDeviceId, OwnedUserId};
18
19/// Customized version of `ruma_client_api::keys::get_keys::v3::Request`,
20/// without any references.
21#[derive(Clone, Debug)]
22pub struct KeysQueryRequest {
23 /// The time (in milliseconds) to wait when downloading keys from remote
24 /// servers. 10 seconds is the recommended default.
25 pub timeout: Option<Duration>,
26
27 /// The keys to be downloaded. An empty list indicates all devices for
28 /// the corresponding user.
29 pub device_keys: BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>,
30}
31
32impl KeysQueryRequest {
33 pub(crate) fn new(users: impl Iterator<Item = OwnedUserId>) -> Self {
34 let device_keys = users.map(|u| (u, Vec::new())).collect();
35
36 Self { timeout: None, device_keys }
37 }
38}