5 releases (breaking)

0.5.0 Oct 4, 2023
0.4.0 Feb 21, 2022
0.3.0 Jan 11, 2022
0.2.0 Oct 21, 2021
0.1.0 Jun 28, 2020

#32 in HTTP client

Download history 6938/week @ 2023-10-22 8240/week @ 2023-10-29 7669/week @ 2023-11-05 9568/week @ 2023-11-12 8875/week @ 2023-11-19 11451/week @ 2023-11-26 9866/week @ 2023-12-03 9814/week @ 2023-12-10 7828/week @ 2023-12-17 6077/week @ 2023-12-24 7519/week @ 2023-12-31 9328/week @ 2024-01-07 9271/week @ 2024-01-14 10611/week @ 2024-01-21 10474/week @ 2024-01-28 10436/week @ 2024-02-04

41,492 downloads per month
Used in 93 crates (17 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–18MB
~264K SLoC