5 releases (breaking)

0.5.0 Apr 22, 2020
0.4.0 Sep 15, 2019
0.3.0 Nov 4, 2017
0.2.0 Feb 9, 2017
0.1.0 May 27, 2016

#451 in HTTP client

Download history 23/week @ 2024-11-13 22/week @ 2024-11-20 20/week @ 2024-11-27 33/week @ 2024-12-04 43/week @ 2024-12-11 34/week @ 2024-12-18 35/week @ 2024-12-25 49/week @ 2025-01-01 61/week @ 2025-01-08 24/week @ 2025-01-15 7/week @ 2025-01-22 40/week @ 2025-01-29 101/week @ 2025-02-05 15/week @ 2025-02-12 35/week @ 2025-02-19 50/week @ 2025-02-26

216 downloads per month

MIT license

17KB
241 lines

EventSource

crates.io Documentation Build Status

EventSource is a Rust library for reading from Server-Sent Events endpoints. It transparently sends HTTP requests and only exposes a stream of events to the user. It handles automatic reconnection and parsing of the text/event-stream data format.

Examples

use eventsource::reqwest::Client;
use reqwest::Url;
                                                                                              
fn main() {
    let client = Client::new(Url::parse("http://example.com").unwrap());
    for event in client {
        println!("{}", event.unwrap());
    }
}

lib.rs:

EventSource

EventSource is a Rust library for reading from Server-Sent Events endpoints. It transparently sends HTTP requests and only exposes a stream of events to the user. It handles automatic reconnection and parsing of the text/event-stream data format.

Examples

use eventsource::reqwest::Client;
use reqwest::Url;

fn main() {
    let client = Client::new(Url::parse("http://example.com").unwrap());
    for event in client {
        println!("{}", event.unwrap());
    }
}

Dependencies

~2–12MB
~150K SLoC