Add hashes getter to StateEvent

This commit is contained in:
Devin Ragotzy 2020-08-18 16:00:13 -04:00
parent ce2d5a0d9b
commit 8650f8fea7

View File

@ -3,7 +3,7 @@ use std::{collections::BTreeMap, convert::TryFrom};
use ruma::{
events::{
from_raw_json_value,
pdu::{Pdu, PduStub},
pdu::{EventHash, Pdu, PduStub},
room::member::{MemberEventContent, MembershipState},
EventDeHelper, EventType,
},
@ -273,6 +273,19 @@ impl StateEvent {
}
}
pub fn hashes(&self) -> &EventHash {
match self {
Self::Full(ev) => match ev {
Pdu::RoomV1Pdu(ev) => &ev.hashes,
Pdu::RoomV3Pdu(ev) => &ev.hashes,
},
Self::Sync(ev) => match ev {
PduStub::RoomV1PduStub(ev) => &ev.hashes,
PduStub::RoomV3PduStub(ev) => &ev.hashes,
},
}
}
pub fn is_type_and_key(&self, ev_type: EventType, state_key: &str) -> bool {
match self {
Self::Full(ev) => match ev {