Expand description

Client for the Server-Sent Events protocol (aka EventSource).

use futures::{TryStreamExt};
use eventsource_client::{Client, SSE};
let mut client = eventsource_client::ClientBuilder::for_url("https://example.com/stream")?
    .header("Authorization", "Basic username:password")?
    .build();

let mut stream = Box::pin(client.stream())
    .map_ok(|event| match event {
        SSE::Comment(comment) => println!("got a comment event: {:?}", comment),
        SSE::Event(evt) => println!("got an event: {}", evt.event_type)
    })
    .map_err(|e| println!("error streaming events: {:?}", e));

Structs

Enums

  • Error type returned from this library’s functions.

Constants

Traits

  • Client is the Server-Sent-Events interface. This trait is sealed and cannot be implemented for types outside this crate.

Type Aliases