continuwuity/src/core/pdu/event.rs
Jason Volk 6c9ecb031a re-export ruma Event trait through core pdu
Signed-off-by: Jason Volk <jason@zemos.net>
2024-10-27 21:38:49 +00:00

31 lines
1,002 B
Rust

use std::sync::Arc;
pub use ruma::state_res::Event;
use ruma::{events::TimelineEventType, EventId, MilliSecondsSinceUnixEpoch, RoomId, UserId};
use serde_json::value::RawValue as RawJsonValue;
use super::PduEvent;
impl Event for PduEvent {
type Id = Arc<EventId>;
fn event_id(&self) -> &Self::Id { &self.event_id }
fn room_id(&self) -> &RoomId { &self.room_id }
fn sender(&self) -> &UserId { &self.sender }
fn event_type(&self) -> &TimelineEventType { &self.kind }
fn content(&self) -> &RawJsonValue { &self.content }
fn origin_server_ts(&self) -> MilliSecondsSinceUnixEpoch { MilliSecondsSinceUnixEpoch(self.origin_server_ts) }
fn state_key(&self) -> Option<&str> { self.state_key.as_deref() }
fn prev_events(&self) -> impl DoubleEndedIterator<Item = &Self::Id> + Send + '_ { self.prev_events.iter() }
fn auth_events(&self) -> impl DoubleEndedIterator<Item = &Self::Id> + Send + '_ { self.auth_events.iter() }
fn redacts(&self) -> Option<&Self::Id> { self.redacts.as_ref() }
}