Function tor_circmgr::mgr::streams::select_biased

source ·
pub(super) fn select_biased<S, T>(left: S, right: T) -> SelectBiased<S, T>
where S: Stream, T: Stream<Item = S::Item>,
Expand description

Combine two instances of [Stream] into one.

This function is similar to [futures::stream::select], but differs in that it treats the two underlying streams asymmetrically. Specifically:

  • Each result is labeled with Source::Left or Source::Right, depending on which of the two streams it came from.
  • If both the “left” and the “right” stream are ready, we always prefer the left stream.
  • We stop iterating over this stream when there are no more results on the left stream, regardless whether the right stream is exhausted or not.

§Future plans

This might need a better name, especially if we use it anywhere else.

If we do expose this function, we might want to split up the ways in which it differs from select.