1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Client for the [Server-Sent Events] protocol (aka [EventSource]).
//!
//! This library provides SSE protocol support but requires you to bring your own
//! HTTP transport. See the `examples/` directory for reference implementations using
//! popular HTTP clients like hyper and reqwest.
//!
//! # Getting Started
//!
//! ```ignore
//! use futures::TryStreamExt;
//! use eventsource_client::{Client, ClientBuilder, SSE};
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // You need to implement HttpTransport trait for your HTTP client
//! # struct MyTransport;
//! # impl launchdarkly_sdk_transport::HttpTransport for MyTransport {
//! # fn request(&self, _req: http::Request<Option<String>>) -> eventsource_client::ResponseFuture {
//! # unimplemented!()
//! # }
//! # }
//! let transport = MyTransport::new();
//!
//! let client = ClientBuilder::for_url("https://example.com/stream")?
//! .header("Authorization", "Bearer token")?
//! .build_with_transport(transport);
//!
//! let mut stream = client.stream();
//!
//! while let Some(event) = stream.try_next().await? {
//! match event {
//! SSE::Event(evt) => println!("Event: {}", evt.event_type),
//! SSE::Comment(comment) => println!("Comment: {}", comment),
//! SSE::Connected(_) => println!("Connected!"),
//! }
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # Implementing a Transport
//!
//! See the [`transport`] module documentation for details on implementing
//! the [`HttpTransport`] trait.
//!
//! [`HttpTransport`]: HttpTransport
//!
//! [Server-Sent Events]: https://html.spec.whatwg.org/multipage/server-sent-events.html
//! [EventSource]: https://developer.mozilla.org/en-US/docs/Web/API/EventSource
pub use *;
pub use *;
pub use *;
pub use Event;
pub use SSE;
pub use Response;