Revise trait implementations

This commit is contained in:
Jonas Platte 2020-05-02 14:12:49 +02:00
parent a512df0321
commit ca5c65ef10
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
24 changed files with 115 additions and 140 deletions

View File

@ -95,7 +95,7 @@ impl ToTokens for RumaEvent {
Content::Struct(fields) => { Content::Struct(fields) => {
quote! { quote! {
#[doc = #content_docstring] #[doc = #content_docstring]
#[derive(Clone, Debug, PartialEq, serde::Serialize)] #[derive(Clone, Debug, serde::Serialize)]
pub struct #content_name { pub struct #content_name {
#(#fields),* #(#fields),*
} }
@ -116,7 +116,7 @@ impl ToTokens for RumaEvent {
Content::Struct(fields) => { Content::Struct(fields) => {
quote! { quote! {
#[doc = #content_docstring] #[doc = #content_docstring]
#[derive(Clone, Debug, PartialEq, serde::Deserialize)] #[derive(Clone, Debug, serde::Deserialize)]
pub struct #content_name { pub struct #content_name {
#(#fields),* #(#fields),*
} }
@ -216,7 +216,7 @@ impl ToTokens for RumaEvent {
let event_type_name = self.event_type.value(); let event_type_name = self.event_type.value();
let output = quote!( let output = quote!(
#(#attrs)* #(#attrs)*
#[derive(Clone, PartialEq, Debug, serde::Serialize, ruma_events_macros::FromRaw)] #[derive(Clone, Debug, serde::Serialize, ruma_events_macros::FromRaw)]
#[serde(rename = #event_type_name, tag = "type")] #[serde(rename = #event_type_name, tag = "type")]
pub struct #name { pub struct #name {
#(#event_fields),* #(#event_fields),*
@ -250,7 +250,7 @@ impl ToTokens for RumaEvent {
use super::*; use super::*;
#(#attrs)* #(#attrs)*
#[derive(Clone, Debug, PartialEq, serde::Deserialize)] #[derive(Clone, Debug, serde::Deserialize)]
pub struct #name { pub struct #name {
#(#event_fields),* #(#event_fields),*
} }

View File

@ -1,14 +1,10 @@
use std::{ use std::fmt::{Display, Formatter, Result as FmtResult};
borrow::Cow,
fmt::{Display, Formatter, Result as FmtResult},
};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// An encryption algorithm to be used to encrypt messages sent to a room. /// An encryption algorithm to be used to encrypt messages sent to a room.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
// Cow<str> because deserialization sometimes needs to copy to unescape things #[serde(from = "String", into = "String")]
#[serde(from = "Cow<'_, str>", into = "String")]
pub enum Algorithm { pub enum Algorithm {
/// Olm version 1 using Curve25519, AES-256, and SHA-256. /// Olm version 1 using Curve25519, AES-256, and SHA-256.
OlmV1Curve25519AesSha2, OlmV1Curve25519AesSha2,
@ -40,22 +36,19 @@ impl Display for Algorithm {
} }
} }
impl From<Cow<'_, str>> for Algorithm { impl<T> From<T> for Algorithm
fn from(s: Cow<'_, str>) -> Algorithm { where
match &s as &str { T: Into<String> + AsRef<str>,
{
fn from(s: T) -> Algorithm {
match s.as_ref() {
"m.olm.v1.curve25519-aes-sha2" => Algorithm::OlmV1Curve25519AesSha2, "m.olm.v1.curve25519-aes-sha2" => Algorithm::OlmV1Curve25519AesSha2,
"m.megolm.v1.aes-sha2" => Algorithm::MegolmV1AesSha2, "m.megolm.v1.aes-sha2" => Algorithm::MegolmV1AesSha2,
_ => Algorithm::Custom(s.into_owned()), _ => Algorithm::Custom(s.into()),
} }
} }
} }
impl From<&str> for Algorithm {
fn from(s: &str) -> Algorithm {
Algorithm::from(Cow::Borrowed(s))
}
}
impl From<Algorithm> for String { impl From<Algorithm> for String {
fn from(algorithm: Algorithm) -> String { fn from(algorithm: Algorithm) -> String {
algorithm.to_string() algorithm.to_string()

View File

@ -25,7 +25,7 @@ ruma_event! {
} }
/// An ICE (Interactive Connectivity Establishment) candidate. /// An ICE (Interactive Connectivity Establishment) candidate.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Candidate { pub struct Candidate {
/// The SDP "a" line of the candidate. /// The SDP "a" line of the candidate.

View File

@ -10,7 +10,7 @@ use serde::Serialize;
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;
/// A custom event not covered by the Matrix specification. /// A custom event not covered by the Matrix specification.
#[derive(Clone, Debug, FromRaw, PartialEq, Serialize)] #[derive(Clone, Debug, FromRaw, Serialize)]
pub struct CustomEvent { pub struct CustomEvent {
/// The event's content. /// The event's content.
pub content: CustomEventContent, pub content: CustomEventContent,
@ -38,7 +38,7 @@ impl Event for CustomEvent {
} }
/// A custom room event not covered by the Matrix specification. /// A custom room event not covered by the Matrix specification.
#[derive(Clone, Debug, FromRaw, PartialEq, Serialize)] #[derive(Clone, Debug, FromRaw, Serialize)]
pub struct CustomRoomEvent { pub struct CustomRoomEvent {
/// The event's content. /// The event's content.
pub content: CustomRoomEventContent, pub content: CustomRoomEventContent,
@ -108,7 +108,7 @@ impl RoomEvent for CustomRoomEvent {
} }
/// A custom state event not covered by the Matrix specification. /// A custom state event not covered by the Matrix specification.
#[derive(Clone, Debug, FromRaw, PartialEq, Serialize)] #[derive(Clone, Debug, FromRaw, Serialize)]
pub struct CustomStateEvent { pub struct CustomStateEvent {
/// The event's content. /// The event's content.
pub content: CustomStateEventContent, pub content: CustomStateEventContent,
@ -204,7 +204,7 @@ pub(crate) mod raw {
}; };
/// A custom event not covered by the Matrix specification. /// A custom event not covered by the Matrix specification.
#[derive(Clone, Debug, PartialEq, Deserialize)] #[derive(Clone, Debug, Deserialize)]
pub struct CustomEvent { pub struct CustomEvent {
/// The event's content. /// The event's content.
pub content: CustomEventContent, pub content: CustomEventContent,
@ -214,7 +214,7 @@ pub(crate) mod raw {
} }
/// A custom room event not covered by the Matrix specification. /// A custom room event not covered by the Matrix specification.
#[derive(Clone, Debug, PartialEq, Deserialize)] #[derive(Clone, Debug, Deserialize)]
pub struct CustomRoomEvent { pub struct CustomRoomEvent {
/// The event's content. /// The event's content.
pub content: CustomRoomEventContent, pub content: CustomRoomEventContent,
@ -236,7 +236,7 @@ pub(crate) mod raw {
} }
/// A custom state event not covered by the Matrix specification. /// A custom state event not covered by the Matrix specification.
#[derive(Clone, Debug, PartialEq, Deserialize)] #[derive(Clone, Debug, Deserialize)]
pub struct CustomStateEvent { pub struct CustomStateEvent {
/// The event's content. /// The event's content.
pub content: CustomStateEventContent, pub content: CustomStateEventContent,

View File

@ -1,14 +1,10 @@
use std::{ use std::fmt::{Display, Formatter, Result as FmtResult};
borrow::Cow,
fmt::{Display, Formatter, Result as FmtResult},
};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// The type of an event. /// The type of an event.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
// Cow<str> because deserialization sometimes needs to copy to unescape things #[serde(from = "String", into = "String")]
#[serde(from = "Cow<'_, str>", into = "String")]
pub enum EventType { pub enum EventType {
/// m.call.answer /// m.call.answer
CallAnswer, CallAnswer,
@ -204,9 +200,12 @@ impl Display for EventType {
} }
} }
impl From<Cow<'_, str>> for EventType { impl<T> From<T> for EventType
fn from(s: Cow<'_, str>) -> EventType { where
match &s as &str { T: Into<String> + AsRef<str>,
{
fn from(s: T) -> EventType {
match s.as_ref() {
"m.call.answer" => EventType::CallAnswer, "m.call.answer" => EventType::CallAnswer,
"m.call.candidates" => EventType::CallCandidates, "m.call.candidates" => EventType::CallCandidates,
"m.call.hangup" => EventType::CallHangup, "m.call.hangup" => EventType::CallHangup,
@ -250,17 +249,11 @@ impl From<Cow<'_, str>> for EventType {
"m.sticker" => EventType::Sticker, "m.sticker" => EventType::Sticker,
"m.tag" => EventType::Tag, "m.tag" => EventType::Tag,
"m.typing" => EventType::Typing, "m.typing" => EventType::Typing,
_ => EventType::Custom(s.into_owned()), _ => EventType::Custom(s.into()),
} }
} }
} }
impl<'a> From<&str> for EventType {
fn from(s: &str) -> EventType {
EventType::from(Cow::Borrowed(s))
}
}
impl From<EventType> for String { impl From<EventType> for String {
fn from(event_type: EventType) -> String { fn from(event_type: EventType) -> String {
event_type.to_string() event_type.to_string()

View File

@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
use crate::{EventType, FromRaw}; use crate::{EventType, FromRaw};
/// A list of users to ignore. /// A list of users to ignore.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
#[serde(rename = "m.ignored_user_list", tag = "type")] #[serde(rename = "m.ignored_user_list", tag = "type")]
pub struct IgnoredUserListEvent { pub struct IgnoredUserListEvent {
/// The event's content. /// The event's content.
@ -24,7 +24,7 @@ impl FromRaw for IgnoredUserListEvent {
} }
/// The payload for `IgnoredUserListEvent`. /// The payload for `IgnoredUserListEvent`.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
pub struct IgnoredUserListEventContent { pub struct IgnoredUserListEventContent {
/// A list of users to ignore. /// A list of users to ignore.
#[serde(with = "ruma_serde::vec_as_map_of_empty")] #[serde(with = "ruma_serde::vec_as_map_of_empty")]

View File

@ -95,12 +95,6 @@ impl<T> Debug for EventJson<T> {
} }
} }
impl<T> PartialEq for EventJson<T> {
fn eq(&self, other: &Self) -> bool {
self.json.get() == other.json.get()
}
}
impl<'de, T> Deserialize<'de> for EventJson<T> { impl<'de, T> Deserialize<'de> for EventJson<T> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where where

View File

@ -1,9 +1,6 @@
//! Types for the *m.key.verification.cancel* event. //! Types for the *m.key.verification.cancel* event.
use std::{ use std::fmt::{Display, Formatter, Result as FmtResult};
borrow::Cow,
fmt::{Display, Formatter, Result as FmtResult},
};
use ruma_events_macros::ruma_event; use ruma_events_macros::ruma_event;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -34,8 +31,7 @@ ruma_event! {
/// ///
/// Custom error codes should use the Java package naming convention. /// Custom error codes should use the Java package naming convention.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
// Cow<str> because deserialization sometimes needs to copy to unescape things #[serde(from = "String", into = "String")]
#[serde(from = "Cow<'_, str>", into = "String")]
pub enum CancelCode { pub enum CancelCode {
/// The user cancelled the verification. /// The user cancelled the verification.
User, User,
@ -103,9 +99,12 @@ impl Display for CancelCode {
} }
} }
impl From<Cow<'_, str>> for CancelCode { impl<T> From<T> for CancelCode
fn from(s: Cow<'_, str>) -> CancelCode { where
match &s as &str { T: Into<String> + AsRef<str>,
{
fn from(s: T) -> CancelCode {
match s.as_ref() {
"m.user" => CancelCode::User, "m.user" => CancelCode::User,
"m.timeout" => CancelCode::Timeout, "m.timeout" => CancelCode::Timeout,
"m.unknown_transaction" => CancelCode::UnknownTransaction, "m.unknown_transaction" => CancelCode::UnknownTransaction,
@ -115,17 +114,11 @@ impl From<Cow<'_, str>> for CancelCode {
"m.user_mismatch" => CancelCode::UserMismatch, "m.user_mismatch" => CancelCode::UserMismatch,
"m.invalid_message" => CancelCode::InvalidMessage, "m.invalid_message" => CancelCode::InvalidMessage,
"m.accepted" => CancelCode::Accepted, "m.accepted" => CancelCode::Accepted,
_ => CancelCode::Custom(s.into_owned()), _ => CancelCode::Custom(s.into()),
} }
} }
} }
impl From<&str> for CancelCode {
fn from(s: &str) -> CancelCode {
CancelCode::from(Cow::Borrowed(s))
}
}
impl From<CancelCode> for String { impl From<CancelCode> for String {
fn from(cancel_code: CancelCode) -> String { fn from(cancel_code: CancelCode) -> String {
cancel_code.to_string() cancel_code.to_string()

View File

@ -12,7 +12,7 @@ use crate::{EventType, InvalidInput, TryFromRaw};
/// Begins an SAS key verification process. /// Begins an SAS key verification process.
/// ///
/// Typically sent as a to-device event. /// Typically sent as a to-device event.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
#[serde(tag = "type", rename = "m.key.verification.start")] #[serde(tag = "type", rename = "m.key.verification.start")]
pub struct StartEvent { pub struct StartEvent {
/// The event's content. /// The event's content.
@ -20,7 +20,7 @@ pub struct StartEvent {
} }
/// The payload of an *m.key.verification.start* event. /// The payload of an *m.key.verification.start* event.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum StartEventContent { pub enum StartEventContent {
/// The *m.sas.v1* verification method. /// The *m.sas.v1* verification method.
@ -103,14 +103,14 @@ pub(crate) mod raw {
/// Begins an SAS key verification process. /// Begins an SAS key verification process.
/// ///
/// Typically sent as a to-device event. /// Typically sent as a to-device event.
#[derive(Clone, Debug, PartialEq, Deserialize)] #[derive(Clone, Debug, Deserialize)]
pub struct StartEvent { pub struct StartEvent {
/// The event's content. /// The event's content.
pub content: StartEventContent, pub content: StartEventContent,
} }
/// The payload of an *m.key.verification.start* event. /// The payload of an *m.key.verification.start* event.
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug)]
pub enum StartEventContent { pub enum StartEventContent {
/// The *m.sas.v1* verification method. /// The *m.sas.v1* verification method.
MSasV1(MSasV1Content), MSasV1(MSasV1Content),
@ -158,7 +158,7 @@ pub(crate) mod raw {
} }
/// The payload of an *m.key.verification.start* event using the *m.sas.v1* method. /// The payload of an *m.key.verification.start* event using the *m.sas.v1* method.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "method", rename = "m.sas.v1")] #[serde(tag = "method", rename = "m.sas.v1")]
pub struct MSasV1Content { pub struct MSasV1Content {
/// The device ID which is initiating the process. /// The device ID which is initiating the process.
@ -193,7 +193,7 @@ pub struct MSasV1Content {
} }
/// Options for creating an `MSasV1Content` with `MSasV1Content::new`. /// Options for creating an `MSasV1Content` with `MSasV1Content::new`.
#[derive(Clone, Debug, PartialEq, Deserialize)] #[derive(Clone, Debug, Deserialize)]
pub struct MSasV1ContentOptions { pub struct MSasV1ContentOptions {
/// The device ID which is initiating the process. /// The device ID which is initiating the process.
pub from_device: DeviceId, pub from_device: DeviceId,

View File

@ -224,7 +224,7 @@ pub trait StateEvent: RoomEvent {
/// Extra information about an event that is not incorporated into the event's /// Extra information about an event that is not incorporated into the event's
/// hash. /// hash.
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct UnsignedData { pub struct UnsignedData {
/// The time in milliseconds that has elapsed since the event was sent. This /// The time in milliseconds that has elapsed since the event was sent. This
/// field is generated by the local homeserver, and may be incorrect if the /// field is generated by the local homeserver, and may be incorrect if the
@ -232,9 +232,11 @@ pub struct UnsignedData {
/// cause the age to either be negative or greater than it actually is. /// cause the age to either be negative or greater than it actually is.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub age: Option<Int>, pub age: Option<Int>,
/// The event that redacted this event, if any. /// The event that redacted this event, if any.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub redacted_because: Option<EventJson<RedactionEvent>>, pub redacted_because: Option<EventJson<RedactionEvent>>,
/// The client-supplied transaction ID, if the client being given the event /// The client-supplied transaction ID, if the client being given the event
/// is the same one which sent it. /// is the same one which sent it.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]

View File

@ -31,7 +31,7 @@ ruma_event! {
/// ///
/// For example, some rules may only be applied for messages from a particular sender, a particular /// For example, some rules may only be applied for messages from a particular sender, a particular
/// room, or by default. The push ruleset contains the entire set of scopes and rules. /// room, or by default. The push ruleset contains the entire set of scopes and rules.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Ruleset { pub struct Ruleset {
/// These rules configure behaviour for (unencrypted) messages that match certain patterns. /// These rules configure behaviour for (unencrypted) messages that match certain patterns.
pub content: Vec<PatternedPushRule>, pub content: Vec<PatternedPushRule>,
@ -56,7 +56,7 @@ pub struct Ruleset {
/// ///
/// These rules are stored on the user's homeserver. They are manually configured by the user, who /// These rules are stored on the user's homeserver. They are manually configured by the user, who
/// can create and view them via the Client/Server API. /// can create and view them via the Client/Server API.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PushRule { pub struct PushRule {
/// Actions to determine if and how a notification is delivered for events matching this rule. /// Actions to determine if and how a notification is delivered for events matching this rule.
pub actions: Vec<Action>, pub actions: Vec<Action>,
@ -74,7 +74,7 @@ pub struct PushRule {
/// Like `PushRule`, but with an additional `conditions` field. /// Like `PushRule`, but with an additional `conditions` field.
/// ///
/// Only applicable to underride and override rules. /// Only applicable to underride and override rules.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ConditionalPushRule { pub struct ConditionalPushRule {
/// Actions to determine if and how a notification is delivered for events matching this rule. /// Actions to determine if and how a notification is delivered for events matching this rule.
pub actions: Vec<Action>, pub actions: Vec<Action>,
@ -97,7 +97,7 @@ pub struct ConditionalPushRule {
/// Like `PushRule`, but with an additional `pattern` field. /// Like `PushRule`, but with an additional `pattern` field.
/// ///
/// Only applicable to content rules. /// Only applicable to content rules.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PatternedPushRule { pub struct PatternedPushRule {
/// Actions to determine if and how a notification is delivered for events matching this rule. /// Actions to determine if and how a notification is delivered for events matching this rule.
pub actions: Vec<Action>, pub actions: Vec<Action>,
@ -116,7 +116,7 @@ pub struct PatternedPushRule {
} }
/// An action affects if and how a notification is delivered for a matching event. /// An action affects if and how a notification is delivered for a matching event.
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug)]
pub enum Action { pub enum Action {
/// This causes each matching event to generate a notification. /// This causes each matching event to generate a notification.
Notify, Notify,
@ -229,7 +229,7 @@ impl<'de> Deserialize<'de> for Action {
} }
/// Values for the `set_tweak` action. /// Values for the `set_tweak` action.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "set_tweak", rename_all = "lowercase")] #[serde(tag = "set_tweak", rename_all = "lowercase")]
pub enum Tweak { pub enum Tweak {
/// A string representing the sound to be played when this notification arrives. /// A string representing the sound to be played when this notification arrives.
@ -256,7 +256,7 @@ pub enum Tweak {
} }
/// A condition that must apply for an associated push rule's action to be taken. /// A condition that must apply for an associated push rule's action to be taken.
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug)]
pub enum PushCondition { pub enum PushCondition {
/// This is a glob pattern match on a field of the event. /// This is a glob pattern match on a field of the event.
EventMatch(EventMatchCondition), EventMatch(EventMatchCondition),
@ -355,7 +355,7 @@ impl<'de> Deserialize<'de> for PushCondition {
} }
/// A push condition that matches a glob pattern match on a field of the event. /// A push condition that matches a glob pattern match on a field of the event.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "kind", rename = "event_match")] #[serde(tag = "kind", rename = "event_match")]
pub struct EventMatchCondition { pub struct EventMatchCondition {
/// The dot-separated field of the event to match. /// The dot-separated field of the event to match.
@ -369,7 +369,7 @@ pub struct EventMatchCondition {
} }
/// A push condition that matches the current number of members in the room. /// A push condition that matches the current number of members in the room.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "kind", rename = "room_member_count")] #[serde(tag = "kind", rename = "room_member_count")]
pub struct RoomMemberCountCondition { pub struct RoomMemberCountCondition {
/// A decimal integer optionally prefixed by one of `==`, `<`, `>`, `>=` or `<=`. /// A decimal integer optionally prefixed by one of `==`, `<`, `>`, `>=` or `<=`.
@ -381,7 +381,7 @@ pub struct RoomMemberCountCondition {
/// A push condition that takes into account the current power levels in the room, ensuring the /// A push condition that takes into account the current power levels in the room, ensuring the
/// sender of the event has high enough power to trigger the notification. /// sender of the event has high enough power to trigger the notification.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "kind", rename = "sender_notification_permission")] #[serde(tag = "kind", rename = "sender_notification_permission")]
pub struct SenderNotificationPermissionCondition { pub struct SenderNotificationPermissionCondition {
/// The field in the power level event the user needs a minimum power level for. /// The field in the power level event the user needs a minimum power level for.

View File

@ -29,7 +29,7 @@ ruma_event! {
} }
/// A collection of receipts. /// A collection of receipts.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Receipts { pub struct Receipts {
/// A collection of users who have sent *m.read* receipts for this event. /// A collection of users who have sent *m.read* receipts for this event.
#[serde(default, rename = "m.read")] #[serde(default, rename = "m.read")]
@ -42,7 +42,7 @@ pub struct Receipts {
pub type UserReceipts = BTreeMap<UserId, Receipt>; pub type UserReceipts = BTreeMap<UserId, Receipt>;
/// An acknowledgement of an event. /// An acknowledgement of an event.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Receipt { pub struct Receipt {
/// The time when the receipt was sent. /// The time when the receipt was sent.
#[serde( #[serde(

View File

@ -28,7 +28,7 @@ pub mod tombstone;
pub mod topic; pub mod topic;
/// Metadata about an image. /// Metadata about an image.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ImageInfo { pub struct ImageInfo {
/// The height of the image in pixels. /// The height of the image in pixels.
#[serde(rename = "h", skip_serializing_if = "Option::is_none")] #[serde(rename = "h", skip_serializing_if = "Option::is_none")]
@ -60,7 +60,7 @@ pub struct ImageInfo {
} }
/// Metadata about a thumbnail. /// Metadata about a thumbnail.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ThumbnailInfo { pub struct ThumbnailInfo {
/// The height of the thumbnail in pixels. /// The height of the thumbnail in pixels.
#[serde(rename = "h", skip_serializing_if = "Option::is_none")] #[serde(rename = "h", skip_serializing_if = "Option::is_none")]
@ -80,7 +80,7 @@ pub struct ThumbnailInfo {
} }
/// A file sent to a room with end-to-end encryption enabled. /// A file sent to a room with end-to-end encryption enabled.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EncryptedFile { pub struct EncryptedFile {
/// The URL to the file. /// The URL to the file.
pub url: String, pub url: String,
@ -100,7 +100,7 @@ pub struct EncryptedFile {
} }
/// A [JSON Web Key](https://tools.ietf.org/html/rfc7517#appendix-A.3) object. /// A [JSON Web Key](https://tools.ietf.org/html/rfc7517#appendix-A.3) object.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct JsonWebKey { pub struct JsonWebKey {
/// Key type. Must be `oct`. /// Key type. Must be `oct`.
pub kty: String, pub kty: String,

View File

@ -32,7 +32,7 @@ ruma_event! {
} }
/// A reference to an old room replaced during a room version upgrade. /// A reference to an old room replaced during a room version upgrade.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PreviousRoom { pub struct PreviousRoom {
/// The ID of the old room. /// The ID of the old room.
pub room_id: RoomId, pub room_id: RoomId,

View File

@ -12,7 +12,7 @@ use crate::{Algorithm, EventType, FromRaw, UnsignedData};
/// ///
/// This type is to be used within a room. For a to-device event, use `EncryptedEventContent` /// This type is to be used within a room. For a to-device event, use `EncryptedEventContent`
/// directly. /// directly.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
#[serde(tag = "type", rename = "m.room.encrypted")] #[serde(tag = "type", rename = "m.room.encrypted")]
pub struct EncryptedEvent { pub struct EncryptedEvent {
/// The event's content. /// The event's content.
@ -33,12 +33,12 @@ pub struct EncryptedEvent {
pub sender: UserId, pub sender: UserId,
/// Additional key-value pairs not signed by the homeserver. /// Additional key-value pairs not signed by the homeserver.
#[serde(skip_serializing_if = "ruma_serde::is_default")] #[serde(skip_serializing_if = "UnsignedData::is_empty")]
pub unsigned: UnsignedData, pub unsigned: UnsignedData,
} }
/// The payload for `EncryptedEvent`. /// The payload for `EncryptedEvent`.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum EncryptedEventContent { pub enum EncryptedEventContent {
/// An event encrypted with *m.olm.v1.curve25519-aes-sha2*. /// An event encrypted with *m.olm.v1.curve25519-aes-sha2*.
@ -106,7 +106,7 @@ pub(crate) mod raw {
/// ///
/// This type is to be used within a room. For a to-device event, use `EncryptedEventContent` /// This type is to be used within a room. For a to-device event, use `EncryptedEventContent`
/// directly. /// directly.
#[derive(Clone, Debug, PartialEq, Deserialize)] #[derive(Clone, Debug, Deserialize)]
pub struct EncryptedEvent { pub struct EncryptedEvent {
/// The event's content. /// The event's content.
pub content: EncryptedEventContent, pub content: EncryptedEventContent,
@ -130,7 +130,7 @@ pub(crate) mod raw {
} }
/// The payload for `EncryptedEvent`. /// The payload for `EncryptedEvent`.
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug)]
pub enum EncryptedEventContent { pub enum EncryptedEventContent {
/// An event encrypted with *m.olm.v1.curve25519-aes-sha2*. /// An event encrypted with *m.olm.v1.curve25519-aes-sha2*.
OlmV1Curve25519AesSha2(OlmV1Curve25519AesSha2Content), OlmV1Curve25519AesSha2(OlmV1Curve25519AesSha2Content),
@ -192,7 +192,7 @@ pub(crate) mod raw {
} }
/// The payload for `EncryptedEvent` using the *m.olm.v1.curve25519-aes-sha2* algorithm. /// The payload for `EncryptedEvent` using the *m.olm.v1.curve25519-aes-sha2* algorithm.
#[derive(Clone, Debug, Serialize, PartialEq, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub struct OlmV1Curve25519AesSha2Content { pub struct OlmV1Curve25519AesSha2Content {
/// The encryption algorithm used to encrypt this event. /// The encryption algorithm used to encrypt this event.
pub algorithm: Algorithm, pub algorithm: Algorithm,
@ -207,7 +207,7 @@ pub struct OlmV1Curve25519AesSha2Content {
/// Ciphertext information holding the ciphertext and message type. /// Ciphertext information holding the ciphertext and message type.
/// ///
/// Used for messages encrypted with the *m.olm.v1.curve25519-aes-sha2* algorithm. /// Used for messages encrypted with the *m.olm.v1.curve25519-aes-sha2* algorithm.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CiphertextInfo { pub struct CiphertextInfo {
/// The encrypted payload. /// The encrypted payload.
pub body: String, pub body: String,
@ -218,7 +218,7 @@ pub struct CiphertextInfo {
} }
/// The payload for `EncryptedEvent` using the *m.megolm.v1.aes-sha2* algorithm. /// The payload for `EncryptedEvent` using the *m.megolm.v1.aes-sha2* algorithm.
#[derive(Clone, Debug, Serialize, PartialEq, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub struct MegolmV1AesSha2Content { pub struct MegolmV1AesSha2Content {
/// The encryption algorithm used to encrypt this event. /// The encryption algorithm used to encrypt this event.
pub algorithm: Algorithm, pub algorithm: Algorithm,

View File

@ -99,7 +99,7 @@ impl_enum! {
} }
/// Information about a third party invitation. /// Information about a third party invitation.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ThirdPartyInvite { pub struct ThirdPartyInvite {
/// A name which can be displayed to represent the user instead of their third party /// A name which can be displayed to represent the user instead of their third party
/// identifier. /// identifier.
@ -112,7 +112,7 @@ pub struct ThirdPartyInvite {
/// A block of content which has been signed, which servers can use to verify a third party /// A block of content which has been signed, which servers can use to verify a third party
/// invitation. /// invitation.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SignedContent { pub struct SignedContent {
/// The invited Matrix user ID. /// The invited Matrix user ID.
/// ///
@ -128,7 +128,7 @@ pub struct SignedContent {
} }
/// Translation of the membership change in `m.room.member` event. /// Translation of the membership change in `m.room.member` event.
#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub enum MembershipChange { pub enum MembershipChange {
/// No change. /// No change.
None, None,

View File

@ -12,7 +12,7 @@ use crate::{EventType, FromRaw, UnsignedData};
pub mod feedback; pub mod feedback;
/// A message sent to a room. /// A message sent to a room.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
#[serde(rename = "m.room.message", tag = "type")] #[serde(rename = "m.room.message", tag = "type")]
pub struct MessageEvent { pub struct MessageEvent {
/// The event's content. /// The event's content.
@ -39,7 +39,7 @@ pub struct MessageEvent {
/// The payload for `MessageEvent`. /// The payload for `MessageEvent`.
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum MessageEventContent { pub enum MessageEventContent {
/// An audio message. /// An audio message.
@ -135,7 +135,7 @@ pub(crate) mod raw {
use crate::UnsignedData; use crate::UnsignedData;
/// A message sent to a room. /// A message sent to a room.
#[derive(Clone, Debug, PartialEq, Deserialize)] #[derive(Clone, Debug, Deserialize)]
pub struct MessageEvent { pub struct MessageEvent {
/// The event's content. /// The event's content.
pub content: MessageEventContent, pub content: MessageEventContent,
@ -160,7 +160,7 @@ pub(crate) mod raw {
/// The payload for `MessageEvent`. /// The payload for `MessageEvent`.
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug)]
pub enum MessageEventContent { pub enum MessageEventContent {
/// An audio message. /// An audio message.
Audio(AudioMessageEventContent), Audio(AudioMessageEventContent),
@ -295,7 +295,7 @@ pub enum MessageType {
} }
/// The payload for an audio message. /// The payload for an audio message.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "msgtype", rename = "m.audio")] #[serde(tag = "msgtype", rename = "m.audio")]
pub struct AudioMessageEventContent { pub struct AudioMessageEventContent {
/// The textual representation of this message. /// The textual representation of this message.
@ -316,7 +316,7 @@ pub struct AudioMessageEventContent {
} }
/// Metadata about an audio clip. /// Metadata about an audio clip.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AudioInfo { pub struct AudioInfo {
/// The duration of the audio in milliseconds. /// The duration of the audio in milliseconds.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -332,7 +332,7 @@ pub struct AudioInfo {
} }
/// The payload for an emote message. /// The payload for an emote message.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "msgtype", rename = "m.emote")] #[serde(tag = "msgtype", rename = "m.emote")]
pub struct EmoteMessageEventContent { pub struct EmoteMessageEventContent {
/// The emote action to perform. /// The emote action to perform.
@ -349,7 +349,7 @@ pub struct EmoteMessageEventContent {
} }
/// The payload for a file message. /// The payload for a file message.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "msgtype", rename = "m.file")] #[serde(tag = "msgtype", rename = "m.file")]
pub struct FileMessageEventContent { pub struct FileMessageEventContent {
/// A human-readable description of the file. This is recommended to be the filename of the /// A human-readable description of the file. This is recommended to be the filename of the
@ -375,7 +375,7 @@ pub struct FileMessageEventContent {
} }
/// Metadata about a file. /// Metadata about a file.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct FileInfo { pub struct FileInfo {
/// The mimetype of the file, e.g. "application/msword." /// The mimetype of the file, e.g. "application/msword."
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -399,7 +399,7 @@ pub struct FileInfo {
} }
/// The payload for an image message. /// The payload for an image message.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "msgtype", rename = "m.image")] #[serde(tag = "msgtype", rename = "m.image")]
pub struct ImageMessageEventContent { pub struct ImageMessageEventContent {
/// A textual representation of the image. This could be the alt text of the image, the filename /// A textual representation of the image. This could be the alt text of the image, the filename
@ -421,7 +421,7 @@ pub struct ImageMessageEventContent {
} }
/// The payload for a location message. /// The payload for a location message.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "msgtype", rename = "m.location")] #[serde(tag = "msgtype", rename = "m.location")]
pub struct LocationMessageEventContent { pub struct LocationMessageEventContent {
/// A description of the location e.g. "Big Ben, London, UK,"or some kind of content description /// A description of the location e.g. "Big Ben, London, UK,"or some kind of content description
@ -437,7 +437,7 @@ pub struct LocationMessageEventContent {
} }
/// Thumbnail info associated with a location. /// Thumbnail info associated with a location.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct LocationInfo { pub struct LocationInfo {
/// Metadata about the image referred to in `thumbnail_url` or `thumbnail_file`. /// Metadata about the image referred to in `thumbnail_url` or `thumbnail_file`.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -455,7 +455,7 @@ pub struct LocationInfo {
} }
/// The payload for a notice message. /// The payload for a notice message.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "msgtype", rename = "m.notice")] #[serde(tag = "msgtype", rename = "m.notice")]
pub struct NoticeMessageEventContent { pub struct NoticeMessageEventContent {
/// The notice text to send. /// The notice text to send.
@ -477,7 +477,7 @@ pub struct NoticeMessageEventContent {
} }
/// The payload for a server notice message. /// The payload for a server notice message.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "msgtype", rename = "m.server_notice")] #[serde(tag = "msgtype", rename = "m.server_notice")]
pub struct ServerNoticeMessageEventContent { pub struct ServerNoticeMessageEventContent {
/// A human-readable description of the notice. /// A human-readable description of the notice.
@ -500,7 +500,7 @@ pub struct ServerNoticeMessageEventContent {
} }
/// Types of server notices. /// Types of server notices.
#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub enum ServerNoticeType { pub enum ServerNoticeType {
/// The server has exceeded some limit which requires the server administrator to intervene. /// The server has exceeded some limit which requires the server administrator to intervene.
#[serde(rename = "m.server_notice.usage_limit_reached")] #[serde(rename = "m.server_notice.usage_limit_reached")]
@ -514,7 +514,7 @@ pub enum ServerNoticeType {
} }
/// Types of usage limits. /// Types of usage limits.
#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub enum LimitType { pub enum LimitType {
/// The server's number of active users in the last 30 days has exceeded the maximum. /// The server's number of active users in the last 30 days has exceeded the maximum.
/// ///
@ -531,7 +531,7 @@ pub enum LimitType {
} }
/// The payload for a text message. /// The payload for a text message.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "msgtype", rename = "m.text")] #[serde(tag = "msgtype", rename = "m.text")]
pub struct TextMessageEventContent { pub struct TextMessageEventContent {
/// The body of the message. /// The body of the message.
@ -553,7 +553,7 @@ pub struct TextMessageEventContent {
} }
/// The payload for a video message. /// The payload for a video message.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "msgtype", rename = "m.video")] #[serde(tag = "msgtype", rename = "m.video")]
pub struct VideoMessageEventContent { pub struct VideoMessageEventContent {
/// A description of the video, e.g. "Gangnam Style," or some kind of content description for /// A description of the video, e.g. "Gangnam Style," or some kind of content description for
@ -575,7 +575,7 @@ pub struct VideoMessageEventContent {
} }
/// Metadata about a video. /// Metadata about a video.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct VideoInfo { pub struct VideoInfo {
/// The duration of the video in milliseconds. /// The duration of the video in milliseconds.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -615,7 +615,7 @@ pub struct VideoInfo {
/// Information about related messages for /// Information about related messages for
/// [rich replies](https://matrix.org/docs/spec/client_server/r0.5.0#rich-replies). /// [rich replies](https://matrix.org/docs/spec/client_server/r0.5.0#rich-replies).
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct RelatesTo { pub struct RelatesTo {
/// Information about another message being replied to. /// Information about another message being replied to.
#[serde(rename = "m.in_reply_to")] #[serde(rename = "m.in_reply_to")]
@ -623,7 +623,7 @@ pub struct RelatesTo {
} }
/// Information about the event a "rich reply" is replying to. /// Information about the event a "rich reply" is replying to.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct InReplyTo { pub struct InReplyTo {
/// The event being replied to. /// The event being replied to.
pub event_id: EventId, pub event_id: EventId,

View File

@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
use crate::{EventType, InvalidInput, TryFromRaw, UnsignedData}; use crate::{EventType, InvalidInput, TryFromRaw, UnsignedData};
/// A human-friendly room name designed to be displayed to the end-user. /// A human-friendly room name designed to be displayed to the end-user.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
#[serde(rename = "m.room.name", tag = "type")] #[serde(rename = "m.room.name", tag = "type")]
pub struct NameEvent { pub struct NameEvent {
/// The event's content. /// The event's content.
@ -36,12 +36,12 @@ pub struct NameEvent {
pub state_key: String, pub state_key: String,
/// Additional key-value pairs not signed by the homeserver. /// Additional key-value pairs not signed by the homeserver.
#[serde(skip_serializing_if = "ruma_serde::is_default")] #[serde(skip_serializing_if = "UnsignedData::is_empty")]
pub unsigned: UnsignedData, pub unsigned: UnsignedData,
} }
/// The payload for `NameEvent`. /// The payload for `NameEvent`.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
pub struct NameEventContent { pub struct NameEventContent {
/// The name of the room. This MUST NOT exceed 255 bytes. /// The name of the room. This MUST NOT exceed 255 bytes.
pub(crate) name: Option<String>, pub(crate) name: Option<String>,
@ -109,7 +109,7 @@ pub(crate) mod raw {
use super::*; use super::*;
/// A human-friendly room name designed to be displayed to the end-user. /// A human-friendly room name designed to be displayed to the end-user.
#[derive(Clone, Debug, PartialEq, Deserialize)] #[derive(Clone, Debug, Deserialize)]
pub struct NameEvent { pub struct NameEvent {
/// The event's content. /// The event's content.
pub content: NameEventContent, pub content: NameEventContent,
@ -139,7 +139,7 @@ pub(crate) mod raw {
} }
/// The payload of a `NameEvent`. /// The payload of a `NameEvent`.
#[derive(Clone, Debug, PartialEq, Deserialize)] #[derive(Clone, Debug, Deserialize)]
pub struct NameEventContent { pub struct NameEventContent {
/// The name of the room. This MUST NOT exceed 255 bytes. /// The name of the room. This MUST NOT exceed 255 bytes.
// The spec says "A room with an m.room.name event with an absent, null, or empty name field // The spec says "A room with an m.room.name event with an absent, null, or empty name field

View File

@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
use crate::{EventType, FromRaw, UnsignedData}; use crate::{EventType, FromRaw, UnsignedData};
/// An event to indicate which servers are permitted to participate in the room. /// An event to indicate which servers are permitted to participate in the room.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
#[serde(rename = "m.room.server_acl", tag = "type")] #[serde(rename = "m.room.server_acl", tag = "type")]
pub struct ServerAclEvent { pub struct ServerAclEvent {
/// The event's content. /// The event's content.
@ -41,7 +41,7 @@ pub struct ServerAclEvent {
} }
/// The payload for `ServerAclEvent`. /// The payload for `ServerAclEvent`.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
pub struct ServerAclEventContent { pub struct ServerAclEventContent {
/// True to allow server names that are IP address literals. False to deny. Defaults to true if /// True to allow server names that are IP address literals. False to deny. Defaults to true if
/// missing or otherwise not a boolean. /// missing or otherwise not a boolean.
@ -108,7 +108,7 @@ pub(crate) mod raw {
use super::*; use super::*;
/// An event to indicate which servers are permitted to participate in the room. /// An event to indicate which servers are permitted to participate in the room.
#[derive(Clone, Debug, PartialEq, Deserialize)] #[derive(Clone, Debug, Deserialize)]
pub struct ServerAclEvent { pub struct ServerAclEvent {
/// The event's content. /// The event's content.
pub content: ServerAclEventContent, pub content: ServerAclEventContent,
@ -138,7 +138,7 @@ pub(crate) mod raw {
} }
/// The payload for `ServerAclEvent`. /// The payload for `ServerAclEvent`.
#[derive(Clone, Debug, PartialEq, Deserialize)] #[derive(Clone, Debug, Deserialize)]
pub struct ServerAclEventContent { pub struct ServerAclEventContent {
/// True to allow server names that are IP address literals. False to deny. Defaults to true /// True to allow server names that are IP address literals. False to deny. Defaults to true
/// if missing or otherwise not a boolean. /// if missing or otherwise not a boolean.

View File

@ -30,7 +30,7 @@ ruma_event! {
} }
/// A public key for signing a third party invite token. /// A public key for signing a third party invite token.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PublicKey { pub struct PublicKey {
/// An optional URL which can be fetched to validate whether the key has been revoked. /// An optional URL which can be fetched to validate whether the key has been revoked.
/// ///

View File

@ -60,7 +60,7 @@ impl_enum! {
} }
/// Information about a requested key. /// Information about a requested key.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct RequestedKeyInfo { pub struct RequestedKeyInfo {
/// The encryption algorithm the requested key in this event is to be used with. /// The encryption algorithm the requested key in this event is to be used with.
pub algorithm: Algorithm, pub algorithm: Algorithm,

View File

@ -65,7 +65,7 @@ pub enum AnyStrippedStateEvent {
} }
/// A "stripped-down" version of a core state event. /// A "stripped-down" version of a core state event.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
pub struct StrippedStateEvent<C> { pub struct StrippedStateEvent<C> {
/// Data specific to the event type. /// Data specific to the event type.
pub content: C, pub content: C,

View File

@ -18,7 +18,7 @@ ruma_event! {
} }
/// Information about a tag. /// Information about a tag.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct TagInfo { pub struct TagInfo {
/// Value to use for lexicographically ordering rooms with this tag. /// Value to use for lexicographically ordering rooms with this tag.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]

View File

@ -24,7 +24,7 @@ use crate::{
/// To-device versions of events that will appear in the to-device part of a /// To-device versions of events that will appear in the to-device part of a
/// sync response. /// sync response.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum AnyToDeviceEvent { pub enum AnyToDeviceEvent {
/// To-device version of the "m.dummy" event. /// To-device version of the "m.dummy" event.
@ -51,7 +51,7 @@ pub enum AnyToDeviceEvent {
KeyVerificationRequest(ToDeviceVerificationRequest), KeyVerificationRequest(ToDeviceVerificationRequest),
} }
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, Serialize)]
/// To-device event. /// To-device event.
pub struct ToDeviceEvent<C> { pub struct ToDeviceEvent<C> {
/// The unique identifier for the user who sent this event. /// The unique identifier for the user who sent this event.