Crate eventsource_stream[][src]

Expand description

A basic building block for building an Eventsource from a Stream of bytes array like objects. To learn more about Server Sent Events (SSE) take a look at the MDN docs

Example

let mut stream = reqwest::Client::new()
    .get("http://localhost:7020/notifications")
    .send()
    .await?
    .bytes_stream()
    .eventsource();


while let Some(event) = stream.next().await {
    match event {
        Ok(event) => println!(
            "received: {:?}: {}",
            event.event,
            String::from_utf8_lossy(&event.data)
        ),
        Err(e) => eprintln!("error occured: {}", e),
    }
}

Structs

An Event

Provides the Stream implementation for Events

Enums

Wrapper for ParseError and other Transport Errors thrown while collecting the Event stream

Error thrown while parsing an event line

Traits

Main entrypoint for creating Event streams