#sse #eventsource #stream #parse #event

no-std eventsource-stream

A basic building block for building an Eventsource from a Stream of bytes

4 releases

0.2.0 Jan 11, 2022
0.1.2 Oct 21, 2021
0.1.1 Jun 28, 2020
0.1.0 Jun 27, 2020

#51 in HTTP client

Download history 3/week @ 2021-10-02 13/week @ 2021-10-09 25/week @ 2021-10-16 11/week @ 2021-10-23 5/week @ 2021-10-30 5/week @ 2021-11-06 1/week @ 2021-11-13 8/week @ 2021-11-20 11/week @ 2021-11-27 11/week @ 2021-12-04 21/week @ 2021-12-11 7/week @ 2021-12-18 7/week @ 2021-12-25 10/week @ 2022-01-01 31/week @ 2022-01-08 17/week @ 2022-01-15

67 downloads per month
Used in 2 crates (via reqwest-eventsource)

MIT/Apache

29KB
749 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

~1.2–1.7MB
~35K SLoC

a