6 releases (breaking)

0.6.0 Mar 29, 2024
0.5.0 Oct 4, 2023
0.4.0 Feb 21, 2022
0.3.0 Jan 11, 2022
0.1.0 Jun 28, 2020

#15 in HTTP client

Download history 12097/week @ 2024-07-22 11461/week @ 2024-07-29 15435/week @ 2024-08-05 15079/week @ 2024-08-12 15387/week @ 2024-08-19 16656/week @ 2024-08-26 15879/week @ 2024-09-02 16881/week @ 2024-09-09 15756/week @ 2024-09-16 17679/week @ 2024-09-23 16056/week @ 2024-09-30 14880/week @ 2024-10-07 15610/week @ 2024-10-14 16984/week @ 2024-10-21 19014/week @ 2024-10-28 18435/week @ 2024-11-04

70,705 downloads per month
Used in 159 crates (40 directly)

MIT/Apache

21KB
403 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

let mut es = EventSource::get("http://localhost:8000/events");
while let Some(event) = es.next().await {
    match event {
        Ok(Event::Open) => println!("Connection Open!"),
        Ok(Event::Message(message)) => println!("Message: {:#?}", message),
        Err(err) => {
            println!("Error: {}", err);
            es.close();
        }
    }
}

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

let mut es = EventSource::get("http://localhost:8000/events");
while let Some(event) = es.next().await {
    match event {
        Ok(Event::Open) => println!("Connection Open!"),
        Ok(Event::Message(message)) => println!("Message: {:#?}", message),
        Err(err) => {
            println!("Error: {}", err);
            es.close();
        }
    }
}

Dependencies

~5–16MB
~205K SLoC