state-res: Remove unused Event trait methods
This commit is contained in:
parent
c94f9d5c88
commit
9cb9b1104a
@ -528,18 +528,11 @@ fn BAN_STATE_SET() -> HashMap<EventId, Arc<StateEvent>> {
|
||||
}
|
||||
|
||||
mod event {
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use js_int::UInt;
|
||||
use ruma_common::MilliSecondsSinceUnixEpoch;
|
||||
use ruma_events::{
|
||||
pdu::{EventHash, Pdu},
|
||||
EventType,
|
||||
};
|
||||
use ruma_identifiers::{EventId, RoomId, ServerName, ServerSigningKeyId, UserId};
|
||||
use ruma_events::{pdu::Pdu, EventType};
|
||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
||||
use ruma_state_res::Event;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value as JsonValue;
|
||||
|
||||
impl Event for StateEvent {
|
||||
fn event_id(&self) -> &EventId {
|
||||
@ -609,15 +602,6 @@ mod event {
|
||||
}
|
||||
}
|
||||
|
||||
fn depth(&self) -> &UInt {
|
||||
match &self.rest {
|
||||
Pdu::RoomV1Pdu(ev) => &ev.depth,
|
||||
Pdu::RoomV3Pdu(ev) => &ev.depth,
|
||||
#[cfg(not(feature = "unstable-exhaustive-types"))]
|
||||
_ => unreachable!("new PDU version"),
|
||||
}
|
||||
}
|
||||
|
||||
fn auth_events(&self) -> Box<dyn DoubleEndedIterator<Item = &EventId> + '_> {
|
||||
match &self.rest {
|
||||
Pdu::RoomV1Pdu(ev) => Box::new(ev.auth_events.iter().map(|(id, _)| id)),
|
||||
@ -635,33 +619,6 @@ mod event {
|
||||
_ => unreachable!("new PDU version"),
|
||||
}
|
||||
}
|
||||
|
||||
fn hashes(&self) -> &EventHash {
|
||||
match &self.rest {
|
||||
Pdu::RoomV1Pdu(ev) => &ev.hashes,
|
||||
Pdu::RoomV3Pdu(ev) => &ev.hashes,
|
||||
#[cfg(not(feature = "unstable-exhaustive-types"))]
|
||||
_ => unreachable!("new PDU version"),
|
||||
}
|
||||
}
|
||||
|
||||
fn signatures(&self) -> BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>> {
|
||||
match &self.rest {
|
||||
Pdu::RoomV1Pdu(_) => maplit::btreemap! {},
|
||||
Pdu::RoomV3Pdu(ev) => ev.signatures.clone(),
|
||||
#[cfg(not(feature = "unstable-exhaustive-types"))]
|
||||
_ => unreachable!("new PDU version"),
|
||||
}
|
||||
}
|
||||
|
||||
fn unsigned(&self) -> &BTreeMap<String, JsonValue> {
|
||||
match &self.rest {
|
||||
Pdu::RoomV1Pdu(ev) => &ev.unsigned,
|
||||
Pdu::RoomV3Pdu(ev) => &ev.unsigned,
|
||||
#[cfg(not(feature = "unstable-exhaustive-types"))]
|
||||
_ => unreachable!("new PDU version"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
|
@ -1,10 +1,8 @@
|
||||
use std::{collections::BTreeMap, sync::Arc};
|
||||
use std::sync::Arc;
|
||||
|
||||
use js_int::UInt;
|
||||
use ruma_common::MilliSecondsSinceUnixEpoch;
|
||||
use ruma_events::{pdu::EventHash, EventType};
|
||||
use ruma_identifiers::{EventId, RoomId, ServerName, ServerSigningKeyId, UserId};
|
||||
use serde_json::value::Value as JsonValue;
|
||||
use ruma_events::EventType;
|
||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
||||
|
||||
/// Abstraction of a PDU so users can have their own PDU types.
|
||||
pub trait Event {
|
||||
@ -37,27 +35,12 @@ pub trait Event {
|
||||
// Requires GATs to avoid boxing (and TAIT for making it convenient).
|
||||
fn prev_events(&self) -> Box<dyn DoubleEndedIterator<Item = &EventId> + '_>;
|
||||
|
||||
/// The maximum number of `prev_events` plus 1.
|
||||
///
|
||||
/// This is only used in state resolution version 1.
|
||||
fn depth(&self) -> &UInt;
|
||||
|
||||
/// All the authenticating events for this event.
|
||||
// Requires GATs to avoid boxing (and TAIT for making it convenient).
|
||||
fn auth_events(&self) -> Box<dyn DoubleEndedIterator<Item = &EventId> + '_>;
|
||||
|
||||
/// If this event is a redaction event this is the event it redacts.
|
||||
fn redacts(&self) -> Option<&EventId>;
|
||||
|
||||
/// The `unsigned` content of this event.
|
||||
fn unsigned(&self) -> &BTreeMap<String, JsonValue>;
|
||||
|
||||
/// The content hash of this PDU.
|
||||
fn hashes(&self) -> &EventHash;
|
||||
|
||||
/// A map of server names to another map consisting of the signing key id and finally the
|
||||
/// signature.
|
||||
fn signatures(&self) -> BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>>;
|
||||
}
|
||||
|
||||
impl<T: Event> Event for &T {
|
||||
@ -93,10 +76,6 @@ impl<T: Event> Event for &T {
|
||||
(*self).prev_events()
|
||||
}
|
||||
|
||||
fn depth(&self) -> &UInt {
|
||||
(*self).depth()
|
||||
}
|
||||
|
||||
fn auth_events(&self) -> Box<dyn DoubleEndedIterator<Item = &EventId> + '_> {
|
||||
(*self).auth_events()
|
||||
}
|
||||
@ -104,18 +83,6 @@ impl<T: Event> Event for &T {
|
||||
fn redacts(&self) -> Option<&EventId> {
|
||||
(*self).redacts()
|
||||
}
|
||||
|
||||
fn unsigned(&self) -> &BTreeMap<String, JsonValue> {
|
||||
(*self).unsigned()
|
||||
}
|
||||
|
||||
fn hashes(&self) -> &EventHash {
|
||||
(*self).hashes()
|
||||
}
|
||||
|
||||
fn signatures(&self) -> BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>> {
|
||||
(*self).signatures()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Event> Event for Arc<T> {
|
||||
@ -151,10 +118,6 @@ impl<T: Event> Event for Arc<T> {
|
||||
(&**self).prev_events()
|
||||
}
|
||||
|
||||
fn depth(&self) -> &UInt {
|
||||
(&**self).depth()
|
||||
}
|
||||
|
||||
fn auth_events(&self) -> Box<dyn DoubleEndedIterator<Item = &EventId> + '_> {
|
||||
(&**self).auth_events()
|
||||
}
|
||||
@ -162,16 +125,4 @@ impl<T: Event> Event for Arc<T> {
|
||||
fn redacts(&self) -> Option<&EventId> {
|
||||
(&**self).redacts()
|
||||
}
|
||||
|
||||
fn unsigned(&self) -> &BTreeMap<String, JsonValue> {
|
||||
(&**self).unsigned()
|
||||
}
|
||||
|
||||
fn hashes(&self) -> &EventHash {
|
||||
(&**self).hashes()
|
||||
}
|
||||
|
||||
fn signatures(&self) -> BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>> {
|
||||
(&**self).signatures()
|
||||
}
|
||||
}
|
||||
|
@ -528,18 +528,10 @@ pub fn INITIAL_EDGES() -> Vec<EventId> {
|
||||
}
|
||||
|
||||
pub mod event {
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use js_int::UInt;
|
||||
use ruma_events::{
|
||||
exports::ruma_common::MilliSecondsSinceUnixEpoch,
|
||||
pdu::{EventHash, Pdu},
|
||||
EventType,
|
||||
};
|
||||
use ruma_identifiers::{EventId, RoomId, ServerName, ServerSigningKeyId, UserId};
|
||||
use ruma_events::{exports::ruma_common::MilliSecondsSinceUnixEpoch, pdu::Pdu, EventType};
|
||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value as JsonValue;
|
||||
|
||||
use crate::Event;
|
||||
|
||||
@ -611,15 +603,6 @@ pub mod event {
|
||||
}
|
||||
}
|
||||
|
||||
fn depth(&self) -> &UInt {
|
||||
match &self.rest {
|
||||
Pdu::RoomV1Pdu(ev) => &ev.depth,
|
||||
Pdu::RoomV3Pdu(ev) => &ev.depth,
|
||||
#[cfg(not(feature = "unstable-exhaustive-types"))]
|
||||
_ => unreachable!("new PDU version"),
|
||||
}
|
||||
}
|
||||
|
||||
fn auth_events(&self) -> Box<dyn DoubleEndedIterator<Item = &EventId> + '_> {
|
||||
match &self.rest {
|
||||
Pdu::RoomV1Pdu(ev) => Box::new(ev.auth_events.iter().map(|(id, _)| id)),
|
||||
@ -637,33 +620,6 @@ pub mod event {
|
||||
_ => unreachable!("new PDU version"),
|
||||
}
|
||||
}
|
||||
|
||||
fn hashes(&self) -> &EventHash {
|
||||
match &self.rest {
|
||||
Pdu::RoomV1Pdu(ev) => &ev.hashes,
|
||||
Pdu::RoomV3Pdu(ev) => &ev.hashes,
|
||||
#[cfg(not(feature = "unstable-exhaustive-types"))]
|
||||
_ => unreachable!("new PDU version"),
|
||||
}
|
||||
}
|
||||
|
||||
fn signatures(&self) -> BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, String>> {
|
||||
match &self.rest {
|
||||
Pdu::RoomV1Pdu(_) => BTreeMap::new(),
|
||||
Pdu::RoomV3Pdu(ev) => ev.signatures.clone(),
|
||||
#[cfg(not(feature = "unstable-exhaustive-types"))]
|
||||
_ => unreachable!("new PDU version"),
|
||||
}
|
||||
}
|
||||
|
||||
fn unsigned(&self) -> &BTreeMap<String, JsonValue> {
|
||||
match &self.rest {
|
||||
Pdu::RoomV1Pdu(ev) => &ev.unsigned,
|
||||
Pdu::RoomV3Pdu(ev) => &ev.unsigned,
|
||||
#[cfg(not(feature = "unstable-exhaustive-types"))]
|
||||
_ => unreachable!("new PDU version"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user