From bafc2016c6258a8f1c984c2eca13680b4ab50e86 Mon Sep 17 00:00:00 2001 From: Devin Ragotzy Date: Tue, 18 Aug 2020 16:03:24 -0400 Subject: [PATCH] Add origin getter to StateEvent --- src/state_event.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/state_event.rs b/src/state_event.rs index 8c946730..ae6c1e77 100644 --- a/src/state_event.rs +++ b/src/state_event.rs @@ -201,6 +201,18 @@ impl StateEvent { }, } } + pub fn origin(&self) -> String { + match self { + Self::Full(ev) => match ev { + Pdu::RoomV1Pdu(ev) => ev.origin.clone(), + Pdu::RoomV3Pdu(ev) => ev.origin.clone(), + }, + Self::Sync(ev) => match ev { + PduStub::RoomV1PduStub(ev) => ev.origin.clone(), + PduStub::RoomV3PduStub(ev) => ev.origin.clone(), + }, + } + } pub fn prev_event_ids(&self) -> Vec { match self {