Skip to main content

split_conflicted_state

Function split_conflicted_state 

Source
pub(super) async fn split_conflicted_state<'a, Maps, Id>(
    state_maps: Maps,
) -> (StateMap<Id>, ConflictMap<Id>)
where Maps: Stream<Item = StateMap<Id>>, Id: Clone + Eq + Hash + Ord + Send + Sync + 'a,
Expand description

Split the unconflicted state map and the conflicted state set.

Definition in the specification:

If a given key K is present in every Si with the same value V in each state map, then the pair (K, V) belongs to the unconflicted state map. Otherwise, V belongs to the conflicted state set.

It means that, for a given (event type, state key) tuple, if all state maps have the same event ID, it lands in the unconflicted state map, otherwise the event IDs land in the conflicted state set.

§Arguments

  • state_maps - The incoming states to resolve. Each StateMap represents a possible fork in the state of a room.

§Returns

Returns an (unconflicted_state, conflicted_states) tuple.