#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

#184 in Asynchronous

Download history 250/week @ 2022-10-08 238/week @ 2022-10-15 276/week @ 2022-10-22 537/week @ 2022-10-29 355/week @ 2022-11-05 391/week @ 2022-11-12 877/week @ 2022-11-19 990/week @ 2022-11-26 1353/week @ 2022-12-03 1327/week @ 2022-12-10 1267/week @ 2022-12-17 823/week @ 2022-12-24 2026/week @ 2022-12-31 653/week @ 2023-01-07 1245/week @ 2023-01-14 1455/week @ 2023-01-21

5,503 downloads per month
Used in 4 crates (2 directly)

MIT/Apache

30KB
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
~18K SLoC