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

#16 in HTTP client

Download history 11249/week @ 2024-07-10 11499/week @ 2024-07-17 11556/week @ 2024-07-24 12331/week @ 2024-07-31 16506/week @ 2024-08-07 14518/week @ 2024-08-14 15707/week @ 2024-08-21 16216/week @ 2024-08-28 16658/week @ 2024-09-04 17510/week @ 2024-09-11 16191/week @ 2024-09-18 16601/week @ 2024-09-25 16229/week @ 2024-10-02 14088/week @ 2024-10-09 17090/week @ 2024-10-16 18166/week @ 2024-10-23

68,503 downloads per month
Used in 156 crates (39 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

~4–15MB
~210K SLoC