clementine_core::rpc::aggregator

Function collect_and_call

Source
async fn collect_and_call<R, T, F, Fut>(
    rx: &mut Receiver<Vec<T>>,
    f: F,
) -> Result<R, Status>
where R: Default, T: Clone, F: FnMut(Vec<T>) -> Fut, Fut: Future<Output = Result<R, Status>>,
Expand description

Use items collected from the broadcast receiver for an async function call.

Handles the boilerplate of managing a receiver of a broadcast channel. If receiver is lagged at any time (data is lost) an error is returned.