chore(base): Remove unnecessary bounds on MinimalStateEvent
This commit is contained in:
committed by
Jonas Platte
parent
dc08d5f62b
commit
41bcc9bdd7
@@ -16,8 +16,8 @@ use ruma::{
|
||||
redaction::OriginalSyncRoomRedactionEvent, tombstone::RoomTombstoneEventContent,
|
||||
topic::RoomTopicEventContent,
|
||||
},
|
||||
AnyStrippedStateEvent, AnySyncStateEvent, EmptyStateKey, RedactContent,
|
||||
RedactedEventContent, StateEventContent, StrippedStateEvent, SyncStateEvent,
|
||||
AnyStrippedStateEvent, AnySyncStateEvent, RedactContent, RedactedEventContent,
|
||||
StateEventContent, StrippedStateEvent, SyncStateEvent,
|
||||
},
|
||||
EventId, OwnedEventId, OwnedUserId, RoomVersionId,
|
||||
};
|
||||
@@ -30,10 +30,9 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||
//
|
||||
// It is unclear why a Serialize bound on C::Redacted is not also required.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
enum MinimalStateEvent<C: StateEventContent<StateKey = EmptyStateKey> + RedactContent>
|
||||
enum MinimalStateEvent<C: StateEventContent + RedactContent>
|
||||
where
|
||||
C::Redacted:
|
||||
StateEventContent<StateKey = EmptyStateKey> + RedactedEventContent + DeserializeOwned,
|
||||
C::Redacted: StateEventContent + RedactedEventContent + DeserializeOwned,
|
||||
{
|
||||
Original(OriginalMinimalStateEvent<C>),
|
||||
Redacted(RedactedMinimalStateEvent<C::Redacted>),
|
||||
@@ -42,7 +41,7 @@ where
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
struct OriginalMinimalStateEvent<C>
|
||||
where
|
||||
C: StateEventContent<StateKey = EmptyStateKey>,
|
||||
C: StateEventContent,
|
||||
{
|
||||
content: C,
|
||||
event_id: Option<OwnedEventId>,
|
||||
@@ -51,7 +50,7 @@ where
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
struct RedactedMinimalStateEvent<C>
|
||||
where
|
||||
C: StateEventContent<StateKey = EmptyStateKey> + RedactedEventContent,
|
||||
C: StateEventContent + RedactedEventContent,
|
||||
{
|
||||
content: C,
|
||||
event_id: Option<OwnedEventId>,
|
||||
@@ -59,9 +58,8 @@ where
|
||||
|
||||
impl<C> MinimalStateEvent<C>
|
||||
where
|
||||
C: Clone + StateEventContent<StateKey = EmptyStateKey> + RedactContent,
|
||||
C::Redacted:
|
||||
StateEventContent<StateKey = EmptyStateKey> + RedactedEventContent + DeserializeOwned,
|
||||
C: StateEventContent + RedactContent,
|
||||
C::Redacted: StateEventContent + RedactedEventContent + DeserializeOwned,
|
||||
{
|
||||
fn event_id(&self) -> Option<&EventId> {
|
||||
match self {
|
||||
@@ -77,7 +75,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn redact(&mut self, room_version: &RoomVersionId) {
|
||||
fn redact(&mut self, room_version: &RoomVersionId)
|
||||
where
|
||||
C: Clone,
|
||||
{
|
||||
if let MinimalStateEvent::Original(ev) = self {
|
||||
*self = MinimalStateEvent::Redacted(RedactedMinimalStateEvent {
|
||||
content: ev.content.clone().redact(room_version),
|
||||
@@ -89,11 +90,8 @@ where
|
||||
|
||||
impl<C> From<&SyncStateEvent<C>> for MinimalStateEvent<C>
|
||||
where
|
||||
C: Clone + StateEventContent<StateKey = EmptyStateKey> + RedactContent,
|
||||
C::Redacted: Clone
|
||||
+ StateEventContent<StateKey = EmptyStateKey>
|
||||
+ RedactedEventContent
|
||||
+ DeserializeOwned,
|
||||
C: Clone + StateEventContent + RedactContent,
|
||||
C::Redacted: Clone + StateEventContent + RedactedEventContent + DeserializeOwned,
|
||||
{
|
||||
fn from(ev: &SyncStateEvent<C>) -> Self {
|
||||
match ev {
|
||||
@@ -111,11 +109,8 @@ where
|
||||
|
||||
impl<C> From<&StrippedStateEvent<C>> for MinimalStateEvent<C>
|
||||
where
|
||||
C: Clone + StateEventContent<StateKey = EmptyStateKey> + RedactContent,
|
||||
C::Redacted: Clone
|
||||
+ StateEventContent<StateKey = EmptyStateKey>
|
||||
+ RedactedEventContent
|
||||
+ DeserializeOwned,
|
||||
C: Clone + StateEventContent + RedactContent,
|
||||
C::Redacted: StateEventContent + RedactedEventContent + DeserializeOwned,
|
||||
{
|
||||
fn from(ev: &StrippedStateEvent<C>) -> Self {
|
||||
Self::Original(OriginalMinimalStateEvent { content: ev.content.clone(), event_id: None })
|
||||
@@ -337,9 +332,8 @@ trait OptionExt {
|
||||
|
||||
impl<C> OptionExt for Option<MinimalStateEvent<C>>
|
||||
where
|
||||
C: Clone + StateEventContent<StateKey = EmptyStateKey> + RedactContent,
|
||||
C::Redacted:
|
||||
StateEventContent<StateKey = EmptyStateKey> + RedactedEventContent + DeserializeOwned,
|
||||
C: StateEventContent + RedactContent,
|
||||
C::Redacted: StateEventContent + RedactedEventContent + DeserializeOwned,
|
||||
{
|
||||
fn has_event_id(&self, ev_id: &EventId) -> bool {
|
||||
self.as_ref().and_then(|ev| ev.event_id()).map_or(false, |id| id == ev_id)
|
||||
|
||||
Reference in New Issue
Block a user