pub struct EventStream<S> { /* private fields */ }Expand description
Adapter from a stream of byte chunks to a stream of SSE events.
Works with any Stream<Item = Result<B, E>> where B: AsRef<[u8]>,
which covers Vec<u8>, &[u8], bytes::Bytes, and HTTP client
bodies. Executor-agnostic: the only async dependency is the
futures-core Stream trait.
Every completed event is yielded before the inner stream is polled
again. When the inner stream ends, the parser is finished, remaining
events are yielded, and the stream terminates. Polling after
termination returns Ready(None) without touching the inner stream.
A transport error is yielded as an item and the stream stays usable.
Implementations§
Source§impl<S> EventStream<S>
impl<S> EventStream<S>
Sourcepub fn set_last_event_id(&mut self, id: impl Into<String>)
pub fn set_last_event_id(&mut self, id: impl Into<String>)
Seed the last event ID string, for reconnection. Events dispatched
before the stream’s first id field report this ID.
Sourcepub fn last_event_id(&self) -> &str
pub fn last_event_id(&self) -> &str
The last event ID string. See SseParser::last_event_id.
Sourcepub fn retry(&self) -> Option<Duration>
pub fn retry(&self) -> Option<Duration>
Reconnection time from the most recent valid retry field, if any.
See SseParser::retry.
Trait Implementations§
Source§impl<S: Debug> Debug for EventStream<S>
impl<S: Debug> Debug for EventStream<S>
Source§impl<S, B, E> FusedStream for EventStream<S>
impl<S, B, E> FusedStream for EventStream<S>
Source§fn is_terminated(&self) -> bool
fn is_terminated(&self) -> bool
true if the stream should no longer be polled.