sse-core-0.1.0 has been yanked.
sse-core
A high-performance, no_std compatible state-machine parser for Server-Sent
Events (SSE).
sse-core is designed to be the foundational parsing layer for SSE clients. It
does not perform any network I/O. Instead, it provides a highly efficient,
allocation-minimized state machine that consumes raw bytes and yields parsed SSE
events.
Features
no_stdCompatible: Requires only thealloccrate, making it perfect for embedded environments or custom network stacks.- Zero-I/O State Machine: The
SseDecoderoperates strictly on byte buffers (bytes::Buf), decoupling parsing from the transport layer. - Async Stream Wrapper: Includes a lightweight
SseStreamwrapper to easily integrate withfutures-core::TryStream(e.g., standard async network streams). - Memory Efficient: Leverages
Cowfor event names to avoid allocating strings for standard"message"events, and cleanly enforces configurable maximum payload sizes to prevent memory exhaustion from malicious servers. - Jittered Backoff: Includes a customizable mathematical utility
(
SseRetryConfig) for calculating exponential backoffs and reconnect delays.
Usage
The Low-Level Decoder
If you are managing your own buffers, use the SseDecoder directly:
use Bytes;
use SseDecoder;
The Async Stream Wrapper
If you have an existing async byte stream (like a TCP socket or HTTP body), wrap
it in SseStream:
use SseStream;
use StreamExt;
// Assume `tcp_byte_stream` implements `TryStream<Ok = bytes::Bytes>`
let mut stream = new;
while let Some = stream.next.await
Feature Flags
jitter(enabled by default): Includes randomized jitter calculations inSseRetryConfigto prevent thundering herd problems on reconnects. Requires thestdlibrary. Disable this forno_stdusage.