#sse #eventsource #reqwest #stream #event

no-std reqwest-eventsource

Helper to build an Eventsource using reqwest

3 releases (breaking)

0.3.0 Jan 11, 2022
0.2.0 Oct 21, 2021
0.1.0 Jun 28, 2020

#122 in HTTP client

Download history 3/week @ 2021-10-02 6/week @ 2021-10-09 22/week @ 2021-10-16 6/week @ 2021-10-23 4/week @ 2021-10-30 3/week @ 2021-11-06 1/week @ 2021-11-13 9/week @ 2021-11-20 5/week @ 2021-11-27 10/week @ 2021-12-04 17/week @ 2021-12-11 6/week @ 2021-12-18 6/week @ 2021-12-25 11/week @ 2022-01-01 25/week @ 2022-01-08 11/week @ 2022-01-15

56 downloads per month
Used in lucid-kv-client

MIT/Apache

9KB
104 lines

reqwest-eventsource

Provides a simple wrapper for [reqwest] to provide an Event Source implementation. You can learn more about Server Sent Events (SSE) take a look at the MDN docs This crate uses [eventsource_stream] to wrap the underlying Bytes stream, and retries failed requests.

Example

For more examples with delaying and error handling, take a look at the examples/

let client = Client::new();
let mut stream = client
    .get("http://localhost:7020/notifications")
    .eventsource()?;

while let Some(event) = stream.next().await {
    match event {
        Ok(event) => println!(
            "received: {:?}: {}",
            event.event,
            String::from_utf8_lossy(&event.data)
        ),
        Err(e) => eprintln!("error occured: {}", e),
    }
}

License: MIT OR Apache-2.0


lib.rs:

Provides a simple wrapper for [reqwest] to provide an Event Source implementation. You can learn more about Server Sent Events (SSE) take a look at the MDN docs This crate uses [eventsource_stream] to wrap the underlying Bytes stream, and retries failed requests.

Example

For more examples with delaying and error handling, take a look at the examples/

let client = Client::new();
let mut stream = client
    .get("http://localhost:7020/notifications")
    .eventsource()?;

while let Some(event) = stream.next().await {
    match event {
        Ok(event) => println!(
            "received: {:?}: {}",
            event.event,
            String::from_utf8_lossy(&event.data)
        ),
        Err(e) => eprintln!("error occured: {}", e),
    }
}

Dependencies

~3.5–7.5MB
~178K SLoC

a