Matrix State Resolution in Rust!

``rust /// Abstraction of a PDU so users can have their own PDU types. pub trait Event { /// TheEventIdof this event. fn event_id(&self) -> &EventId; /// TheRoomIdof this event. fn room_id(&self) -> &RoomId; /// TheUserId` of this event. fn sender(&self) -> &UserId; // and so on... }

/// A mapping of event type and state_key to some value T, usually an EventId. pub type StateMap = BTreeMap<(EventType, Option), T>;

/// A mapping of EventId to T, usually a StateEvent. pub type EventMap = BTreeMap;

struct StateResolution { // For now the StateResolution struct is empty. If "caching" event_map // between resolve calls ends up being more efficient (probably not, as this would eat memory) // it may have an event_map field. The event_map is all the events // StateResolution has to know about to resolve state. }

impl StateResolution { /// The point of this all, resolve the possibly conflicting sets of events. pub fn resolve( roomid: &RoomId, roomversion: &RoomVersionId, statesets: &[StateMap], authevents: Vec>, event_map: &mut EventMap>, ) -> Result> {; }

```

The StateStore trait is an abstraction around what ever database your server (or maybe even client) uses to store Persistant Data Units.

We use rumas types when deserializing any PDU or it's contents which helps avoid a lot of type checking logic synapse must do while authenticating event chains.