#[non_exhaustive]pub enum StreamEvent {
Connected,
Event(Box<Event>),
Unknown(Value),
}Expand description
A single item yielded by an EventStream.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Connected
The SSE connection opened, or reopened after a reconnect.
Because a reconnect can straddle dropped frames, treat every Connected
as a cue to reconcile against GET /session/{sessionID}/message.
Event(Box<Event>)
A frame that decoded cleanly into the generated event union.
Boxed because Event is a large union; keeping the variant small keeps
StreamEvent (and Result<StreamEvent>) cheap to move.
Unknown(Value)
A frame whose type matched no known Event variant (or whose payload
did not fit the expected shape).
The raw JSON is preserved so callers can inspect newer server events
without this crate erroring out. Only genuinely non-JSON frames surface
as an Err instead.
Implementations§
Source§impl StreamEvent
impl StreamEvent
Sourcepub fn as_event(&self) -> Option<&Event>
pub fn as_event(&self) -> Option<&Event>
The decoded Event, if this item is StreamEvent::Event.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Whether this item marks a fresh (re)connection.
Trait Implementations§
Source§impl Clone for StreamEvent
impl Clone for StreamEvent
Source§fn clone(&self) -> StreamEvent
fn clone(&self) -> StreamEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more