Add depth getter to StateEvent

This commit is contained in:
Devin Ragotzy 2020-08-18 16:06:18 -04:00
parent bafc2016c6
commit 4e9b428c0d

View File

@ -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 {