#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

#147 in Parser implementations

Download history 16073/week @ 2024-10-05 16277/week @ 2024-10-12 18064/week @ 2024-10-19 18423/week @ 2024-10-26 19009/week @ 2024-11-02 18802/week @ 2024-11-09 18689/week @ 2024-11-16 18977/week @ 2024-11-23 21334/week @ 2024-11-30 20215/week @ 2024-12-07 20220/week @ 2024-12-14 10526/week @ 2024-12-21 12724/week @ 2024-12-28 22402/week @ 2025-01-04 25758/week @ 2025-01-11 20721/week @ 2025-01-18

83,280 downloads per month
Used in 214 crates (30 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