#event-source #stream #server-sent-events #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

#192 in Parser implementations

Download history 11407/week @ 2024-03-14 13118/week @ 2024-03-21 10674/week @ 2024-03-28 11719/week @ 2024-04-04 12639/week @ 2024-04-11 12494/week @ 2024-04-18 12045/week @ 2024-04-25 13066/week @ 2024-05-02 12017/week @ 2024-05-09 13398/week @ 2024-05-16 14570/week @ 2024-05-23 13973/week @ 2024-05-30 13112/week @ 2024-06-06 12663/week @ 2024-06-13 12304/week @ 2024-06-20 10136/week @ 2024-06-27

50,263 downloads per month
Used in 164 crates (20 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