#event-stream #event-source #sse #parse #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

#577 in Parser implementations

Download history 10067/week @ 2023-11-21 11205/week @ 2023-11-28 10669/week @ 2023-12-05 9926/week @ 2023-12-12 7411/week @ 2023-12-19 6181/week @ 2023-12-26 8849/week @ 2024-01-02 10350/week @ 2024-01-09 9868/week @ 2024-01-16 11184/week @ 2024-01-23 12272/week @ 2024-01-30 11435/week @ 2024-02-06 11686/week @ 2024-02-13 10682/week @ 2024-02-20 11054/week @ 2024-02-27 10631/week @ 2024-03-05

46,100 downloads per month
Used in 120 crates (11 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
~18K SLoC