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

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

#281 in Parser implementations

Download history 9846/week @ 2024-01-07 9791/week @ 2024-01-14 11210/week @ 2024-01-21 11674/week @ 2024-01-28 11912/week @ 2024-02-04 11396/week @ 2024-02-11 11681/week @ 2024-02-18 10547/week @ 2024-02-25 12616/week @ 2024-03-03 11645/week @ 2024-03-10 12049/week @ 2024-03-17 12705/week @ 2024-03-24 11482/week @ 2024-03-31 11541/week @ 2024-04-07 11881/week @ 2024-04-14 11966/week @ 2024-04-21

47,570 downloads per month
Used in 133 crates (14 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
~21K SLoC