From 4e9b428c0db50ac3a3421ced12a6fd202a1c36a3 Mon Sep 17 00:00:00 2001 From: Devin Ragotzy Date: Tue, 18 Aug 2020 16:06:18 -0400 Subject: [PATCH] Add depth getter to StateEvent --- src/state_event.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/state_event.rs b/src/state_event.rs index ae6c1e77..5830a267 100644 --- a/src/state_event.rs +++ b/src/state_event.rs @@ -1,5 +1,6 @@ use std::{collections::BTreeMap, convert::TryFrom}; +use js_int::UInt; use ruma::{ events::{ from_raw_json_value, @@ -298,6 +299,19 @@ impl StateEvent { } } + pub fn depth(&self) -> &UInt { + match self { + Self::Full(ev) => match ev { + Pdu::RoomV1Pdu(ev) => &ev.depth, + Pdu::RoomV3Pdu(ev) => &ev.depth, + }, + Self::Sync(ev) => match ev { + PduStub::RoomV1PduStub(ev) => &ev.depth, + PduStub::RoomV3PduStub(ev) => &ev.depth, + }, + } + } + pub fn is_type_and_key(&self, ev_type: EventType, state_key: &str) -> bool { match self { Self::Full(ev) => match ev {