eventsource_threaded/lib.rs
1//! # EventSource-Threaded
2//!
3//! EventSource-Threaded is a Rust library for reading from Server-Sent Events endpoints. It transparently
4//! sends HTTP requests on a separate thread and only exposes a stream of events to the user via a channel receiver. It handles automatic
5//! reconnection and parsing of the `text/event-stream` data format.
6//!
7//! # Examples
8//!
9//! ```no_run
10//! use eventsource-threaded::reqwest::Client;
11//! use reqwest::Url;
12//!
13//! fn main() {
14//! let receiver = EventSource::new(Url::parse("http://example.com").unwrap());
15//! loop {
16//! println!("Received Event: {:?}", receiver.recv());
17//! }
18
19//! }
20//! ```
21//!
22
23// Generic text/event-stream parsing and serialization.
24pub mod event;
25// HTTP interface
26#[cfg(feature = "with-reqwest")]
27pub mod eventsource;
28#[cfg(feature = "with-reqwest")]
29mod reqwest;
30
31pub use eventsource::{EventSource, ReceiverSource};