client-api: Remove more PartialEq impls
This commit is contained in:
parent
2257b4daf9
commit
9cc1e20362
@ -1,5 +1,10 @@
|
||||
# [unreleased]
|
||||
|
||||
Breaking changes:
|
||||
|
||||
* Remove `PartialEq` implementations for a number of types
|
||||
* If the lack of such an `impl` causes problems, please open a GitHub issue
|
||||
|
||||
Improvements:
|
||||
|
||||
* Add `From<&UserId>` and `From<&OwnedUserId>` implementations for `UserIdentifier`
|
||||
|
@ -10,7 +10,7 @@ pub mod get_devices;
|
||||
pub mod update_device;
|
||||
|
||||
/// Information about a registered device.
|
||||
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Hash, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct Device {
|
||||
/// Device ID
|
||||
|
@ -57,7 +57,7 @@ impl Response {
|
||||
}
|
||||
|
||||
/// Information about a discovered homeserver.
|
||||
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, PartialOrd, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Hash, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct HomeserverInfo {
|
||||
/// The base URL for the homeserver for client-server connections.
|
||||
@ -72,7 +72,7 @@ impl HomeserverInfo {
|
||||
}
|
||||
|
||||
/// Information about a discovered identity server.
|
||||
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, PartialOrd, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Hash, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct IdentityServerInfo {
|
||||
/// The base URL for the identity server for client-server connections.
|
||||
@ -88,7 +88,7 @@ impl IdentityServerInfo {
|
||||
|
||||
/// Information about a discovered map tile server.
|
||||
#[cfg(feature = "unstable-msc3488")]
|
||||
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, PartialOrd, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Hash, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct TileServerInfo {
|
||||
/// The URL of a map tile server's `style.json` file.
|
||||
|
@ -54,9 +54,8 @@ impl<'a> ThirdPartySigned<'a> {
|
||||
///
|
||||
/// To create an instance of this type, first create a `Invite3pidInit` and convert it via
|
||||
/// `Invite3pid::from` / `.into()`.
|
||||
#[derive(Clone, Debug, PartialEq, Incoming, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(PartialEq)]
|
||||
pub struct Invite3pid<'a> {
|
||||
/// Hostname and port of identity server to be used for account lookups.
|
||||
pub id_server: &'a str,
|
||||
|
@ -62,9 +62,8 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
/// Distinguishes between invititations by Matrix or third party identifiers.
|
||||
#[derive(Clone, Debug, PartialEq, Incoming, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(PartialEq)]
|
||||
#[serde(untagged)]
|
||||
pub enum InvitationRecipient<'a> {
|
||||
/// Used to invite user by their Matrix identifier.
|
||||
@ -79,11 +78,11 @@ pub mod v3 {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use matches::assert_matches;
|
||||
use ruma_common::{thirdparty::Medium, user_id};
|
||||
use serde_json::{from_value as from_json_value, json};
|
||||
|
||||
use super::IncomingInvitationRecipient;
|
||||
use crate::membership::IncomingInvite3pid;
|
||||
|
||||
#[test]
|
||||
fn deserialize_invite_by_user_id() {
|
||||
@ -91,9 +90,12 @@ pub mod v3 {
|
||||
json!({ "user_id": "@carl:example.org" }),
|
||||
)
|
||||
.unwrap();
|
||||
let user_id = user_id!("@carl:example.org").to_owned();
|
||||
let recipient = IncomingInvitationRecipient::UserId { user_id };
|
||||
assert_eq!(incoming, recipient);
|
||||
|
||||
assert_matches!(
|
||||
incoming,
|
||||
IncomingInvitationRecipient::UserId { user_id }
|
||||
if user_id == user_id!("@carl:example.org")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -105,13 +107,16 @@ pub mod v3 {
|
||||
"address": "carl@example.org"
|
||||
}))
|
||||
.unwrap();
|
||||
let recipient = IncomingInvitationRecipient::ThirdPartyId(IncomingInvite3pid {
|
||||
id_server: "example.org".into(),
|
||||
id_access_token: "abcdefghijklmnop".into(),
|
||||
medium: Medium::Email,
|
||||
address: "carl@example.org".into(),
|
||||
});
|
||||
assert_eq!(incoming, recipient);
|
||||
|
||||
let third_party_id = match incoming {
|
||||
IncomingInvitationRecipient::UserId { .. } => panic!("wrong variant"),
|
||||
IncomingInvitationRecipient::ThirdPartyId(id) => id,
|
||||
};
|
||||
|
||||
assert_eq!(third_party_id.id_server, "example.org");
|
||||
assert_eq!(third_party_id.id_access_token, "abcdefghijklmnop");
|
||||
assert_eq!(third_party_id.medium, Medium::Email);
|
||||
assert_eq!(third_party_id.address, "carl@example.org");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user