events: Remove Serialize implementation of unsigned types

This commit is contained in:
Kévin Commaille 2022-12-21 16:42:03 +01:00 committed by Kévin Commaille
parent 67d0f3cc04
commit 2a37e4d109
3 changed files with 9 additions and 17 deletions

View File

@ -126,7 +126,7 @@ pub trait StateEventContent: EventContent<EventType = StateEventType> {
type StateKey: AsRef<str> + Clone + fmt::Debug + DeserializeOwned + Serialize;
/// The type of the event's `unsigned` field.
type Unsigned: Clone + fmt::Debug + Default + CanBeEmpty + StateUnsignedFromParts + Serialize;
type Unsigned: Clone + fmt::Debug + Default + CanBeEmpty + StateUnsignedFromParts;
}
/// Content of a redacted state event.

View File

@ -496,7 +496,7 @@ impl StrippedRoomMemberEvent {
}
/// Extra information about a message event that is not incorporated into the event's hash.
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[derive(Clone, Debug, Default, Deserialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct RoomMemberUnsigned {
/// The time in milliseconds that has elapsed since the event was sent.
@ -504,26 +504,23 @@ pub struct RoomMemberUnsigned {
/// This field is generated by the local homeserver, and may be incorrect if the local time on
/// at least one of the two servers is out of sync, which can cause the age to either be
/// negative or greater than it actually is.
#[serde(skip_serializing_if = "Option::is_none")]
pub age: Option<Int>,
/// The client-supplied transaction ID, if the client being given the event is the same one
/// which sent it.
#[serde(skip_serializing_if = "Option::is_none")]
pub transaction_id: Option<OwnedTransactionId>,
/// Optional previous content of the event.
#[serde(skip_serializing_if = "Option::is_none")]
pub prev_content: Option<RoomMemberEventContent>,
/// State events to assist the receiver in identifying the room.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub invite_room_state: Vec<Raw<AnyStrippedStateEvent>>,
/// [Bundled aggregations] of related child events.
///
/// [Bundled aggregations]: https://spec.matrix.org/v1.4/client-server-api/#aggregations
#[serde(rename = "m.relations", default, skip_serializing_if = "BundledRelations::is_empty")]
#[serde(rename = "m.relations", default)]
pub relations: BundledRelations,
}

View File

@ -1,5 +1,5 @@
use js_int::Int;
use serde::{Deserialize, Serialize};
use serde::Deserialize;
use serde_json::{from_str as from_json_str, value::RawValue as RawJsonValue};
use super::{
@ -11,7 +11,7 @@ use crate::{
};
/// Extra information about a message event that is not incorporated into the event's hash.
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[derive(Clone, Debug, Default, Deserialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct MessageLikeUnsigned {
/// The time in milliseconds that has elapsed since the event was sent.
@ -19,18 +19,16 @@ pub struct MessageLikeUnsigned {
/// This field is generated by the local homeserver, and may be incorrect if the local time on
/// at least one of the two servers is out of sync, which can cause the age to either be
/// negative or greater than it actually is.
#[serde(skip_serializing_if = "Option::is_none")]
pub age: Option<Int>,
/// The client-supplied transaction ID, if the client being given the event is the same one
/// which sent it.
#[serde(skip_serializing_if = "Option::is_none")]
pub transaction_id: Option<OwnedTransactionId>,
/// [Bundled aggregations] of related child events.
///
/// [Bundled aggregations]: https://spec.matrix.org/v1.4/client-server-api/#aggregations
#[serde(rename = "m.relations", default, skip_serializing_if = "BundledRelations::is_empty")]
#[serde(rename = "m.relations", default)]
pub relations: BundledRelations,
}
@ -53,7 +51,7 @@ impl CanBeEmpty for MessageLikeUnsigned {
}
/// Extra information about a state event that is not incorporated into the event's hash.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct StateUnsigned<C: StateEventContent> {
/// The time in milliseconds that has elapsed since the event was sent.
@ -61,22 +59,19 @@ pub struct StateUnsigned<C: StateEventContent> {
/// This field is generated by the local homeserver, and may be incorrect if the local time on
/// at least one of the two servers is out of sync, which can cause the age to either be
/// negative or greater than it actually is.
#[serde(skip_serializing_if = "Option::is_none")]
pub age: Option<Int>,
/// The client-supplied transaction ID, if the client being given the event is the same one
/// which sent it.
#[serde(skip_serializing_if = "Option::is_none")]
pub transaction_id: Option<OwnedTransactionId>,
/// Optional previous content of the event.
#[serde(skip_serializing_if = "Option::is_none")]
pub prev_content: Option<C>,
/// [Bundled aggregations] of related child events.
///
/// [Bundled aggregations]: https://spec.matrix.org/v1.4/client-server-api/#aggregations
#[serde(rename = "m.relations", default, skip_serializing_if = "BundledRelations::is_empty")]
#[serde(rename = "m.relations", default)]
pub relations: BundledRelations,
}