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 waits for readiness or a decode deadline, then wakes the polling
task. The task drains queued events and decodes through a non-blocking poll.
A private notification handle refreshes waits after deadline changes.
The stream yields Some(Ok(event)) for each event. It reports an input or
readiness error once as Some(Err(_)), then fuses to None. Dropping it ends the
helper thread; the shared source is left intact for any other holder.
Source wakes request another readiness pass. Ready events leave wakes pending; a wake alone keeps the stream pending. Use a separate async signal for cancellation.
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).