state-res: Implement Event for Arc<T> where T: Event

This commit is contained in:
Jonas Platte 2021-09-12 00:50:53 +02:00
parent f0cd82dae7
commit a4b8f3bc90
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67

View File

@ -1,4 +1,4 @@
use std::collections::BTreeMap;
use std::{collections::BTreeMap, sync::Arc};
use js_int::UInt;
use ruma_common::MilliSecondsSinceUnixEpoch;
@ -55,3 +55,61 @@ pub trait Event {
/// signature.
fn signatures(&self) -> BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>;
}
impl<T: Event> Event for Arc<T> {
fn event_id(&self) -> &EventId {
(&**self).event_id()
}
fn room_id(&self) -> &RoomId {
(&**self).room_id()
}
fn sender(&self) -> &UserId {
(&**self).sender()
}
fn origin_server_ts(&self) -> MilliSecondsSinceUnixEpoch {
(&**self).origin_server_ts()
}
fn event_type(&self) -> &EventType {
(&**self).event_type()
}
fn content(&self) -> serde_json::Value {
(&**self).content()
}
fn state_key(&self) -> Option<&str> {
(&**self).state_key()
}
fn prev_events(&self) -> Box<dyn DoubleEndedIterator<Item = &EventId> + '_> {
(&**self).prev_events()
}
fn depth(&self) -> &UInt {
(&**self).depth()
}
fn auth_events(&self) -> Box<dyn DoubleEndedIterator<Item = &EventId> + '_> {
(&**self).auth_events()
}
fn redacts(&self) -> Option<&EventId> {
(&**self).redacts()
}
fn unsigned(&self) -> &BTreeMap<String, JsonValue> {
(&**self).unsigned()
}
fn hashes(&self) -> &EventHash {
(&**self).hashes()
}
fn signatures(&self) -> BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>> {
(&**self).signatures()
}
}