Expand description
§reqwest-sse
reqwest-sse is a lightweight Rust library that extends
reqwest by adding native support for handling
Server-Sent Events (SSE)
. It introduces the EventSource trait, which enhances reqwest’s Response
type with an ergonomic .events() method. This method transforms the
response body into an asynchronous Stream of SSE Events, enabling
seamless integration of real-time event handling in applications
using the familiar reqwest HTTP client and the StreamExt API.
§Example
use tokio_stream::StreamExt;
use reqwest_sse::EventSource;
#[tokio::main]
async fn main() {
let mut events = reqwest::get("https://sse.test-free.online/api/story")
.await.unwrap()
.events()
.await.unwrap();
while let Some(Ok(event)) = events.next().await {
println!("{event:?}");
}
}Modules§
Structs§
- Event
- Server-Sent Event representation.
Statics§
- MIME_
EVENT_ STREAM text/event-streamMIME type asHeaderValue.
Traits§
- Event
Source - A trait for consuming a
Responseas aStreamof Server-SentEvents (SSE).