4 releases

Uses new Rust 2024

new 0.1.3 Mar 22, 2025
0.1.2 Mar 21, 2025
0.1.1 Mar 21, 2025
0.1.0 Mar 21, 2025

#1403 in Network programming

Download history 292/week @ 2025-03-17

292 downloads per month
Used in rmcp

MIT/Apache

19KB
281 lines

SSE Stream

Crates.io Version Release status docs.rs

A SSE decoder for Http body

# use sse_stream::SseStream;
# use http_body_util::Full;
# use bytes::Bytes;
# use futures_util::StreamExt;
const SSE_BODY: &str =
r#"
retry: 1000
event: userconnect
data: {"username": "bobby", "time": "02:33:48"}

data: Here's a system message of some kind that will get used
data: to accomplish some task.
"#;

let body = Full::<Bytes>::from(SSE_BODY);
let mut sse_body = SseStream::new(body);
async {
    while let Some(sse) = sse_body.next().await {
        println!("{:?}", sse.unwrap());
    }
};

Dependencies

~1.5MB
~27K SLoC