#server-sent-events #event-source #sse #stream #event-stream #parser #events

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

#151 in Parser implementations

Download history 12936/week @ 2024-06-16 12123/week @ 2024-06-23 10895/week @ 2024-06-30 11244/week @ 2024-07-07 11480/week @ 2024-07-14 12746/week @ 2024-07-21 11527/week @ 2024-07-28 14911/week @ 2024-08-04 16013/week @ 2024-08-11 15840/week @ 2024-08-18 16551/week @ 2024-08-25 16288/week @ 2024-09-01 17676/week @ 2024-09-08 16202/week @ 2024-09-15 18023/week @ 2024-09-22 15593/week @ 2024-09-29

68,286 downloads per month
Used in 181 crates (23 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