ruma_client_api/backup/
get_backup_keys.rs

1//! `GET /_matrix/client/*/room_keys/keys`
2//!
3//! Retrieve all keys from a backup version.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3room_keyskeys
9
10    use std::collections::BTreeMap;
11
12    use ruma_common::{
13        OwnedRoomId,
14        api::{auth_scheme::AccessToken, request, response},
15        metadata,
16    };
17
18    use crate::backup::RoomKeyBackup;
19
20    metadata! {
21        method: GET,
22        rate_limited: true,
23        authentication: AccessToken,
24        history: {
25            unstable => "/_matrix/client/unstable/room_keys/keys",
26            1.0 => "/_matrix/client/r0/room_keys/keys",
27            1.1 => "/_matrix/client/v3/room_keys/keys",
28        }
29    }
30
31    /// Request type for the `get_backup_keys` endpoint.
32    #[request(error = crate::Error)]
33    pub struct Request {
34        /// The backup version to retrieve keys from.
35        #[ruma_api(query)]
36        pub version: String,
37    }
38
39    /// Response type for the `get_backup_keys` endpoint.
40    #[response(error = crate::Error)]
41    pub struct Response {
42        /// A map from room IDs to session IDs to key data.
43        pub rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>,
44    }
45
46    impl Request {
47        /// Creates a new `Request` with the given version.
48        pub fn new(version: String) -> Self {
49            Self { version }
50        }
51    }
52
53    impl Response {
54        /// Creates a new `Response` with the given room key backups.
55        pub fn new(rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>) -> Self {
56            Self { rooms }
57        }
58    }
59}