Skip to main content

sse_parse/
event.rs

1use alloc::string::String;
2use core::time::Duration;
3
4/// One dispatched server-sent event.
5///
6/// The four fields carry the per-event state of the WHATWG processing
7/// model: event type, data, last event ID, and reconnection time.
8#[derive(Debug, Clone, PartialEq, Eq, Default)]
9pub struct Event {
10    /// Event type. `"message"` when the stream set no `event` field for this
11    /// block, or set it to the empty string.
12    pub event: String,
13    /// Event data: the `data` lines of the block joined with `\n`, with the
14    /// trailing `\n` removed.
15    pub data: String,
16    /// The last event ID string at the time of dispatch. Empty until the
17    /// stream sends an `id` field (or the parser is seeded with one).
18    pub id: String,
19    /// The most recent reconnection time processed since the previous
20    /// dispatched event, if any. Use [`SseParser::retry`](crate::SseParser::retry)
21    /// for the current stream-level value.
22    pub retry: Option<Duration>,
23}