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

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

#138 in Parser implementations

Download history 18239/week @ 2024-10-22 18823/week @ 2024-10-29 18327/week @ 2024-11-05 18978/week @ 2024-11-12 18970/week @ 2024-11-19 19346/week @ 2024-11-26 21286/week @ 2024-12-03 19945/week @ 2024-12-10 18723/week @ 2024-12-17 10788/week @ 2024-12-24 13984/week @ 2024-12-31 24522/week @ 2025-01-07 24097/week @ 2025-01-14 25622/week @ 2025-01-21 28055/week @ 2025-01-28 23855/week @ 2025-02-04

106,559 downloads per month
Used in 218 crates (31 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