#event-source #event-stream #events #byte-stream #events-stream #sse #parser

no-std eventsource-stream

A basic building block for building an Eventsource from a Stream of bytes

7 releases

0.2.3 Feb 17, 2022
0.2.2 Feb 11, 2022
0.2.1 Jan 31, 2022
0.1.2 Oct 21, 2021
0.1.1 Jun 28, 2020

#119 in Asynchronous

Download history 20457/week @ 2024-12-08 20087/week @ 2024-12-15 10322/week @ 2024-12-22 12875/week @ 2024-12-29 22585/week @ 2025-01-05 25631/week @ 2025-01-12 25236/week @ 2025-01-19 27089/week @ 2025-01-26 28339/week @ 2025-02-02 29221/week @ 2025-02-09 27734/week @ 2025-02-16 34627/week @ 2025-02-23 33873/week @ 2025-03-02 35723/week @ 2025-03-09 37071/week @ 2025-03-16 37536/week @ 2025-03-23

146,623 downloads per month
Used in 254 crates (33 directly)

MIT/Apache

31KB
770 lines

eventsource-stream

A basic building block for building an Eventsource from a Stream of bytes array like objects. To learn more about Server Sent Events (SSE) take a look at the MDN docs

Example

let mut stream = reqwest::Client::new()
    .get("http://localhost:7020/notifications")
    .send()
    .await?
    .bytes_stream()
    .eventsource();

while let Some(thing) = stream.next().await {
   println!("{:?}", thing);
}

License: MIT OR Apache-2.0


lib.rs:

A basic building block for building an Eventsource from a Stream of bytes array like objects. To learn more about Server Sent Events (SSE) take a look at the MDN docs

Example

let mut stream = reqwest::Client::new()
    .get("http://localhost:7020/notifications")
    .send()
    .await?
    .bytes_stream()
    .eventsource();


while let Some(event) = stream.next().await {
    match event {
        Ok(event) => println!(
            "received event[type={}]: {}",
            event.event,
            event.data
        ),
        Err(e) => eprintln!("error occured: {}", e),
    }
}

Dependencies

~1MB
~20K SLoC