schets / multiqueue

A fast mpmc queue with broadcast capabilities
MIT License
201 stars 29 forks source link

Make `SendError` visible / coercable #19

Open CallumJHays opened 6 years ago

CallumJHays commented 6 years ago

I'm attempting to use BroadcastFutReceiver as a stream combinator to get a Cloneable stream that I can share across threads. I have tried something similar to the following:

fn cloneable<I, E, S>(stream: S) -> BroadcastFutReceiver<I>
where
    I: Clone,
    S: Stream<Item = I, Error = E>,
{
    let (send, recv) = broadcast_fut_queue(1);
    send.send_all(stream); // cannot coerce type E to type SendError<E>
    recv
}

The issue I'm having is I'm not sure how to coerce my generic stream error type implementing T: std::error::Error into a multiqueue::SendError<T> as SendError is not public.