sse-parse 0.1.0

Incremental, linear-time parser for Server-Sent Events byte streams, with a sans-IO core and a runtime-agnostic Stream adapter
Documentation
use alloc::string::String;
use core::time::Duration;

/// One dispatched server-sent event.
///
/// The four fields carry the per-event state of the WHATWG processing
/// model: event type, data, last event ID, and reconnection time.
#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct Event {
    /// Event type. `"message"` when the stream set no `event` field for this
    /// block, or set it to the empty string.
    pub event: String,
    /// Event data: the `data` lines of the block joined with `\n`, with the
    /// trailing `\n` removed.
    pub data: String,
    /// The last event ID string at the time of dispatch. Empty until the
    /// stream sends an `id` field (or the parser is seeded with one).
    pub id: String,
    /// The most recent reconnection time processed since the previous
    /// dispatched event, if any. Use [`SseParser::retry`](crate::SseParser::retry)
    /// for the current stream-level value.
    pub retry: Option<Duration>,
}