ruma_federation_api/
discovery.rs1use std::collections::BTreeMap;
4
5use ruma_common::{
6 serde::Base64, MilliSecondsSinceUnixEpoch, OwnedServerName, OwnedServerSigningKeyId,
7 ServerSignatures,
8};
9use serde::{Deserialize, Serialize};
10
11pub mod discover_homeserver;
12pub mod get_remote_server_keys;
13pub mod get_remote_server_keys_batch;
14pub mod get_server_keys;
15pub mod get_server_version;
16#[cfg(feature = "unstable-msc3723")]
17pub mod get_server_versions;
18
19#[derive(Clone, Debug, Deserialize, Serialize)]
21#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
22pub struct VerifyKey {
23 pub key: Base64,
25}
26
27impl VerifyKey {
28 pub fn new(key: Base64) -> Self {
30 Self { key }
31 }
32}
33
34#[derive(Clone, Debug, Deserialize, Serialize)]
36#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
37pub struct OldVerifyKey {
38 pub expired_ts: MilliSecondsSinceUnixEpoch,
40
41 pub key: Base64,
43}
44
45impl OldVerifyKey {
46 pub fn new(expired_ts: MilliSecondsSinceUnixEpoch, key: Base64) -> Self {
48 Self { expired_ts, key }
49 }
50}
51
52#[derive(Clone, Debug, Deserialize, Serialize)]
54#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
55pub struct ServerSigningKeys {
56 pub server_name: OwnedServerName,
58
59 pub verify_keys: BTreeMap<OwnedServerSigningKeyId, VerifyKey>,
61
62 #[serde(default)]
66 pub old_verify_keys: BTreeMap<OwnedServerSigningKeyId, OldVerifyKey>,
67
68 pub signatures: ServerSignatures,
72
73 pub valid_until_ts: MilliSecondsSinceUnixEpoch,
77}
78
79impl ServerSigningKeys {
80 pub fn new(server_name: OwnedServerName, valid_until_ts: MilliSecondsSinceUnixEpoch) -> Self {
84 Self {
85 server_name,
86 verify_keys: BTreeMap::new(),
87 old_verify_keys: BTreeMap::new(),
88 signatures: ServerSignatures::default(),
89 valid_until_ts,
90 }
91 }
92}