Function resolve

Source
pub fn resolve<'a, E, MapsIter>(
    auth_rules: &AuthorizationRules,
    state_res_rules: &StateResolutionV2Rules,
    state_maps: impl IntoIterator<IntoIter = MapsIter>,
    auth_chains: Vec<HashSet<<E as Event>::Id>>,
    fetch_event: impl Fn(&EventId) -> Option<E>,
    fetch_conflicted_state_subgraph: impl Fn(&HashMap<(StateEventType, String), Vec<<E as Event>::Id>>) -> Option<HashSet<<E as Event>::Id>>,
) -> Result<HashMap<(StateEventType, String), <E as Event>::Id>, Error>
where E: Event + Clone, <E as Event>::Id: 'a, MapsIter: Iterator<Item = &'a HashMap<(StateEventType, String), <E as Event>::Id>> + Clone,
Available on crate feature state-res only.
Expand description

Apply the state resolution algorithm introduced in room version 2 to resolve the state of a room.

§Arguments

  • auth_rules - The authorization rules to apply for the version of the current room.

  • state_res_rules - The state resolution rules to apply for the version of the current room.

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

  • auth_chains - The list of full recursive sets of auth_events for each event in the state_maps.

  • fetch_event - Function to fetch an event in the room given its event ID.

  • fetch_conflicted_state_subgraph - Function to fetch the conflicted state subgraph for the given conflicted state set, for state resolution rules that use it. If it is called and returns None, this function will return an error.

§Invariants

The caller of resolve must ensure that all the events are from the same room.

§Returns

The resolved room state.