[][src]Crate reqwest_eventsource

Provides a simple wrapper for reqwest to provide an Event Source implementation. You can learn more about Server Sent Events (SSE) take a look at the MDN docs This crate uses eventsource_stream to wrap the underlying Bytes stream, and retries failed requests.

Example

For more examples with delaying and error handling, take a look at the examples/

This example is not tested
let client = Client::new();
let mut stream = client
    .get("http://localhost:7020/notifications")
    .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

CannotCloneRequestError

Error raised when a RequestBuilder cannot be cloned. See RequestBuilder::try_clone for more information

Event

An Event

EventsourceRequestBuilder

Provides the Stream implementation for the Event items. This wraps the RequestBuilder and retries requests when they fail.

Enums

Error

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

ParseError

Error thrown while parsing an event line

Traits

RequestBuilderExt

Provides an easy interface to build an EventsourceRequestBuilder from a RequestBuilder