#sse #eventsource #stream #parse #event

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

#3 in #eventsource

Download history 7843/week @ 2023-10-22 9018/week @ 2023-10-29 8335/week @ 2023-11-05 10085/week @ 2023-11-12 9466/week @ 2023-11-19 11844/week @ 2023-11-26 10404/week @ 2023-12-03 10282/week @ 2023-12-10 8267/week @ 2023-12-17 6222/week @ 2023-12-24 7951/week @ 2023-12-31 9884/week @ 2024-01-07 9833/week @ 2024-01-14 11251/week @ 2024-01-21 11726/week @ 2024-01-28 11380/week @ 2024-02-04

44,883 downloads per month
Used in 112 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
~19K SLoC