sync_by_key

Function sync_by_key 

Source
pub fn sync_by_key<I, F, K, S>(
    buf_size: impl Into<Option<usize>>,
    key_fn: F,
    streams: I,
) -> BoxStream<'static, Result<(usize, S::Item), (usize, S::Item)>>
where I: IntoIterator<Item = S>, S: 'static + Stream + Send, S::Item: 'static + Send, F: 'static + Fn(&S::Item) -> K + Send, K: 'static + Clone + Ord + Send,
Expand description

Synchronize streams by pairing up keys of each stream item.

The key_fn constructs the key for each item. The input items are grouped by their keys in the interal buffer until all items with the key arrives. The finished items are yielded in type Ok((stream_index, item)) in monotonic manner.

If any one of the streams generates a non-monotonic item. The item is yielded as Err((stream_index, item)) immediately.