eventsrc
A protocol-correct SSE / EventSource client for Rust, with explicit one-shot and replayable modes.
Overview
eventsrc is organized as a small workspace rather than a single crate:
eventsrc- facade crate
- re-exports the public API from
eventsrc-coreandeventsrc-client
eventsrc-core- 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.
Two Explicit Modes
The 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
Usage
The examples below assume:
- 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 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.