Struct ruma::state_res::StateResolution [−][src]
pub struct StateResolution;
state-res
only.Implementations
impl StateResolution
[src]
impl StateResolution
[src]pub fn resolve<E>(
room_id: &RoomId,
room_version: &RoomVersionId,
state_sets: &[BTreeMap<(EventType, String), EventId>],
auth_events: Vec<Vec<EventId, Global>, Global>,
event_map: &mut BTreeMap<EventId, Arc<E>>
) -> Result<BTreeMap<(EventType, String), EventId>, Error> where
E: Event,
[src]
pub fn resolve<E>(
room_id: &RoomId,
room_version: &RoomVersionId,
state_sets: &[BTreeMap<(EventType, String), EventId>],
auth_events: Vec<Vec<EventId, Global>, Global>,
event_map: &mut BTreeMap<EventId, Arc<E>>
) -> Result<BTreeMap<(EventType, String), EventId>, Error> where
E: Event,
[src]Resolve sets of state events as they come in. Internally StateResolution
builds a graph
and an auth chain to allow for state conflict resolution.
Arguments
-
state_sets
- The incoming state to resolve. EachStateMap
represents a possible fork in the state of a room. -
auth_events
- The full recursive set ofauth_events
for each event in thestate_sets
. -
event_map
- TheEventMap
acts as a local cache of state, any event that is not found in theevent_map
will cause an unrecoverableError
inresolve
.
pub fn separate(
state_sets: &[BTreeMap<(EventType, String), EventId>]
) -> (BTreeMap<(EventType, String), EventId>, BTreeMap<(EventType, String), Vec<EventId, Global>>)
[src]
pub fn separate(
state_sets: &[BTreeMap<(EventType, String), EventId>]
) -> (BTreeMap<(EventType, String), EventId>, BTreeMap<(EventType, String), Vec<EventId, Global>>)
[src]Split the events that have no conflicts from those that are conflicting.
The return tuple looks like (unconflicted, conflicted)
.
State is determined to be conflicting if for the given key (EventType, StateKey) there is not exactly one eventId. This includes missing events, if one state_set includes an event that none of the other have this is a conflicting event.
pub fn get_auth_chain_diff(
_room_id: &RoomId,
auth_event_ids: &[Vec<EventId, Global>]
) -> Result<Vec<EventId, Global>, Error>
[src]
pub fn get_auth_chain_diff(
_room_id: &RoomId,
auth_event_ids: &[Vec<EventId, Global>]
) -> Result<Vec<EventId, Global>, Error>
[src]Returns a Vec of deduped EventIds that appear in some chains but not others.
pub fn reverse_topological_power_sort<E>(
room_id: &RoomId,
events_to_sort: &[EventId],
event_map: &mut BTreeMap<EventId, Arc<E>>,
auth_diff: &[EventId]
) -> Vec<EventId, Global>ⓘ where
E: Event,
[src]
pub fn reverse_topological_power_sort<E>(
room_id: &RoomId,
events_to_sort: &[EventId],
event_map: &mut BTreeMap<EventId, Arc<E>>,
auth_diff: &[EventId]
) -> Vec<EventId, Global>ⓘ where
E: Event,
[src]Events are sorted from “earliest” to “latest”. They are compared using
the negative power level (reverse topological ordering), the
origin server timestamp and incase of a tie the EventId
s
are compared lexicographically.
The power level is negative because a higher power level is equated to an earlier (further back in time) origin server timestamp.
pub fn lexicographical_topological_sort<F>(
graph: &BTreeMap<EventId, Vec<EventId, Global>>,
key_fn: F
) -> Vec<EventId, Global>ⓘ where
F: Fn(&EventId) -> (i64, MilliSecondsSinceUnixEpoch, EventId),
[src]
pub fn lexicographical_topological_sort<F>(
graph: &BTreeMap<EventId, Vec<EventId, Global>>,
key_fn: F
) -> Vec<EventId, Global>ⓘ where
F: Fn(&EventId) -> (i64, MilliSecondsSinceUnixEpoch, EventId),
[src]Sorts the event graph based on number of outgoing/incoming edges, where
key_fn
is used as a tie breaker. The tie breaker happens based on
power level, age, and event_id.
pub fn iterative_auth_check<E>(
room_id: &RoomId,
room_version: &RoomVersion,
events_to_check: &[EventId],
unconflicted_state: &BTreeMap<(EventType, String), EventId>,
event_map: &mut BTreeMap<EventId, Arc<E>>
) -> Result<BTreeMap<(EventType, String), EventId>, Error> where
E: Event,
[src]
pub fn iterative_auth_check<E>(
room_id: &RoomId,
room_version: &RoomVersion,
events_to_check: &[EventId],
unconflicted_state: &BTreeMap<(EventType, String), EventId>,
event_map: &mut BTreeMap<EventId, Arc<E>>
) -> Result<BTreeMap<(EventType, String), EventId>, Error> where
E: Event,
[src]Check the that each event is authenticated based on the events before it.
Returns
The unconflicted_state
combined with the newly auth’ed events. So any event that
fails the event_auth::auth_check
will be excluded from the returned StateMap<EventId>
.
For each events_to_check
event we gather the events needed to auth it from the
event_map
or store
and verify each event using the event_auth::auth_check
function.
pub fn mainline_sort<E>(
room_id: &RoomId,
to_sort: &[EventId],
resolved_power_level: Option<&EventId>,
event_map: &mut BTreeMap<EventId, Arc<E>>
) -> Vec<EventId, Global>ⓘ where
E: Event,
[src]
pub fn mainline_sort<E>(
room_id: &RoomId,
to_sort: &[EventId],
resolved_power_level: Option<&EventId>,
event_map: &mut BTreeMap<EventId, Arc<E>>
) -> Vec<EventId, Global>ⓘ where
E: Event,
[src]Returns the sorted to_sort
list of EventId
s based on a mainline sort using
the depth of resolved_power_level
, the server timestamp, and the eventId.
The depth of the given event is calculated based on the depth of it’s closest “parent” power_level event. If there have been two power events the after the most recent are depth 0, the events before (with the first power level as a parent) will be marked as depth 1. depth 1 is “older” than depth 0.
Trait Implementations
impl Default for StateResolution
[src]
impl Default for StateResolution
[src]pub fn default() -> StateResolution
[src]
pub fn default() -> StateResolution
[src]Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for StateResolution
impl Send for StateResolution
impl Sync for StateResolution
impl Unpin for StateResolution
impl UnwindSafe for StateResolution
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
impl<T> WithSubscriber for T
[src]fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
fn with_current_subscriber(self) -> WithDispatch<Self>
[src]
fn with_current_subscriber(self) -> WithDispatch<Self>
[src]Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more