Improvements: * Add (unstable) support for [MSC3083](https://github.com/matrix-org/matrix-doc/blob/main/proposals/3083-restricted-rooms.md) -----BEGIN PGP SIGNATURE----- iIwEABYIADQWIQSYRl0lv78dXawPPq7MFU3g4wt8ZwUCYUjgYBYcanBsYXR0ZStn aXRAcG9zdGVvLmRlAAoJEMwVTeDjC3xnvF8A/0s7gcm4pijTII7wrIOxB0eWSUgc TSxXIOYpsiDcswnUAP9+PLx+ziy0oxtbPcWK5bil7JBcYwM1tlqIM+d9qlgiCQ== =W1O9 -----END PGP SIGNATURE----- gpgsig -----BEGIN PGP SIGNATURE----- iIwEABYIADQWIQSYRl0lv78dXawPPq7MFU3g4wt8ZwUCYUjgkBYcanBsYXR0ZStn aXRAcG9zdGVvLmRlAAoJEMwVTeDjC3xnrOkBALaAq5RRXvD2xdBD2Q6H9xEPsd/x KSknkjMjqgCJq2g8AQCql0S5QpH8PsmOKDmMO9X6lIHnnaqUxpSOOHIm83VKAA== =9Aii -----END PGP SIGNATURE----- Merge tag 'ruma-events-0.24.6' ruma-events 0.24.6 Improvements: * Add (unstable) support for [MSC3083](https://github.com/matrix-org/matrix-doc/blob/main/proposals/3083-restricted-rooms.md)
Matrix State Resolution in Rust!
/// Abstraction of a PDU so users can have their own PDU types.
pub trait Event {
/// The `EventId` of this event.
fn event_id(&self) -> &EventId;
/// The `RoomId` of this event.
fn room_id(&self) -> &RoomId;
/// The `UserId` 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<T> = BTreeMap<(EventType, Option<String>), T>;
/// A mapping of `EventId` to `T`, usually a `StateEvent`.
pub type EventMap<T> = BTreeMap<EventId, T>;
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<E: Event>(
room_id: &RoomId,
room_version: &RoomVersionId,
state_sets: &[StateMap<EventId>],
auth_events: Vec<Vec<EventId>>,
event_map: &mut EventMap<Arc<E>>,
) -> Result<StateMap<EventId>> {;
}
The StateStore
trait is an abstraction around what ever database your server (or maybe even client) uses to store Persistant Data Units.
We use ruma
s 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.