#event-source #server-sent-events #stream #event-stream #sse #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

#135 in Parser implementations

Download history 18507/week @ 2024-11-15 19002/week @ 2024-11-22 21000/week @ 2024-11-29 20542/week @ 2024-12-06 19756/week @ 2024-12-13 12251/week @ 2024-12-20 12043/week @ 2024-12-27 20384/week @ 2025-01-03 26339/week @ 2025-01-10 24359/week @ 2025-01-17 25895/week @ 2025-01-24 29226/week @ 2025-01-31 29432/week @ 2025-02-07 27205/week @ 2025-02-14 32656/week @ 2025-02-21 28608/week @ 2025-02-28

122,763 downloads per month
Used in 242 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
~19K SLoC