#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

#161 in Parser implementations

Download history 15486/week @ 2024-08-05 15441/week @ 2024-08-12 15879/week @ 2024-08-19 16778/week @ 2024-08-26 16317/week @ 2024-09-02 17740/week @ 2024-09-09 15962/week @ 2024-09-16 18097/week @ 2024-09-23 16694/week @ 2024-09-30 15389/week @ 2024-10-07 16961/week @ 2024-10-14 17404/week @ 2024-10-21 18885/week @ 2024-10-28 19274/week @ 2024-11-04 18681/week @ 2024-11-11 18484/week @ 2024-11-18

76,252 downloads per month
Used in 191 crates (26 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