client-api: Make a few more types non-exhaustive

This commit is contained in:
Jonas Platte 2021-05-01 21:56:07 +02:00
parent 3342deed55
commit f940ff5d11
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
2 changed files with 22 additions and 0 deletions

View File

@ -25,11 +25,19 @@ use serde::{Deserialize, Serialize};
/// A wrapper around a mapping of session IDs to key data.
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct RoomKeyBackup {
/// A map of session IDs to key data.
pub sessions: BTreeMap<String, KeyBackupData>,
}
impl RoomKeyBackup {
/// Creates a new `RoomKeyBackup` with the given sessions.
pub fn new(sessions: BTreeMap<String, KeyBackupData>) -> Self {
Self { sessions }
}
}
/// The algorithm used for storing backups.
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(tag = "algorithm", content = "auth_data")]

View File

@ -22,6 +22,7 @@ use serde::Serialize;
/// A signature of an `m.third_party_invite` token to prove that this user owns a third party
/// identity which has been invited to the room.
#[derive(Clone, Debug, Outgoing, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct ThirdPartySigned<'a> {
/// The Matrix ID of the user who issued the invite.
pub sender: &'a UserId,
@ -36,6 +37,19 @@ pub struct ThirdPartySigned<'a> {
pub signatures: BTreeMap<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>,
}
impl<'a> ThirdPartySigned<'a> {
/// Creates a new `ThirdPartySigned` from the given sender and invitee user IDs, state key token
/// and signatures.
pub fn new(
sender: &'a UserId,
mxid: &'a UserId,
token: &'a str,
signatures: BTreeMap<ServerNameBox, BTreeMap<ServerSigningKeyId, String>>,
) -> Self {
Self { sender, mxid, token, signatures }
}
}
/// Represents third party IDs to invite to the room.
#[derive(Clone, Debug, PartialEq, Outgoing, Serialize)]
#[incoming_derive(PartialEq)]