eventsrc
A protocol-correct SSE / EventSource implementation for Rust, split into a transport-agnostic protocol crate and an explicit client crate.
Overview
eventsrc is organized as a small workspace with two public crates:
eventsrc- transport-agnostic SSE protocol parsing
- exposes
FrameStream<S>andEventStream<S>
eventsrc-client- client-facing one-shot and replayable modes
- owns reconnect, request replay, backend adapter boundaries, and retry
This split keeps protocol logic separate from HTTP client integration. There is no facade crate.
Two Explicit Modes
The eventsrc-client public API keeps two lifecycle models separate:
oneshot::EventSource- consumes one accepted body stream
- does not reconnect
- intended for API streaming and LLM-style responses
replayable::EventSource- reconnects through a backend-neutral connector
- preserves
Last-Event-ID - applies retry policy
- intended for classic EventSource-style subscriptions
Protocol Usage
Use eventsrc when you already have a byte stream and only need SSE protocol parsing.
use Infallible;
use Bytes;
use EventStream;
use ;
# async
Client Usage
The client examples below assume:
- the
eventsrc-clientcrate is used - the default
reqwestfeature is enabled - a Tokio runtime is available
One-Shot Streaming
use EventSourceExt as _;
use StreamExt;
async
Replayable Streaming
use ;
use StreamExt;
use Duration;
async
See eventsrc and
eventsrc-client documentation for more details.
Performance
See benchmarks for more details
License
This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.