pub fn causal<'b, 'a: 'b, E: Envelope<'a>>(
envelopes: &'b mut Vec<E>,
topic_cursor: &'b mut TopicCursor,
) -> impl Sort<Vec<E>> + use<'a, 'b, E>Expand description
Sorts Envelopes Causally in-place
All envelopes part of Self will be sorted. Envelopes with missing
dependencies will be returned. TopicCursor will be updated to reflect
causally-verified envelopes.
XIP Definition
A causal sort orders envelopes by their dependencies.
A dependency is defined as an envelope which must be processed before any
dependant envelopes.
Unsorted (arrival order): Sorted (causal order):
[E3] ──depends on──> [E1] [E1] ───→ [E2] ───→ [E3]
[E1] (no deps) ↑ ↑
[E2] ──depends on──> [E1] │ │
(no deps) (needs E1)
E1 must be processed first, then E2, then E3§Arguments
envelopes: theEnvelope’s being sortedtopic_cursor: the cursor position of all known topics