pub struct EventStream<I: Input> { /* private fields */ }Expand description
A thread-backed [futures_core::Stream] of io::Result<Event> over a
shared EventSource.
Build one with EventSource::into_stream (sole owner) or
EventStream::from_shared (sharing a source kept elsewhere). A helper
thread blocks in EventSource::poll, which reads and decodes input
into the source’s queue, then wakes the polling task; the task drains
queued events (and may itself decode via a non-blocking poll). The stream
yields Some(Ok(event)) per decoded event and, once, Some(Err(_)) on a
read error or end-of-input, then fuses to None. Dropping it ends the
helper thread; the shared source is left intact for any other holder.
Implementations§
Source§impl<I> EventStream<I>where
I: Input + 'static,
impl<I> EventStream<I>where
I: Input + 'static,
Build a stream over a source shared via Arc<Mutex<_>>.
The caller may keep its own clone of the Arc to read the source
synchronously while the stream is live (see the coexistence caveats
on this module).