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