Skip to main content

SseConnExt

Trait SseConnExt 

Source
pub trait SseConnExt {
    // Required methods
    fn with_sse_stream<S, E>(self, sse_stream: S) -> Self
       where S: Stream<Item = E> + Unpin + Send + 'static,
             E: Eventable;
    fn with_sse_stream_and_heartbeat<S, E>(
        self,
        sse_stream: S,
        heartbeat: Duration,
    ) -> Self
       where S: Stream<Item = E> + Unpin + Send + 'static,
             E: Eventable;
}
Expand description

Extension trait for server sent events

Required Methods§

Source

fn with_sse_stream<S, E>(self, sse_stream: S) -> Self
where S: Stream<Item = E> + Unpin + Send + 'static, E: Eventable,

builds and sets a streaming response body that conforms to the server-sent-events spec from a Stream of any Eventable type (such as Event, as well as setting appropiate headers for this response.

Source

fn with_sse_stream_and_heartbeat<S, E>( self, sse_stream: S, heartbeat: Duration, ) -> Self
where S: Stream<Item = E> + Unpin + Send + 'static, E: Eventable,

as with_sse_stream, but sends an empty comment whenever heartbeat elapses without the stream yielding an event.

The interval is measured from the most recent event, not from the start of the response, so a busy stream sends no heartbeats at all. Clients discard the comment.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl SseConnExt for Conn

Source§

fn with_sse_stream<S, E>(self, sse_stream: S) -> Self
where S: Stream<Item = E> + Unpin + Send + 'static, E: Eventable,

Source§

fn with_sse_stream_and_heartbeat<S, E>( self, sse_stream: S, heartbeat: Duration, ) -> Self
where S: Stream<Item = E> + Unpin + Send + 'static, E: Eventable,

Implementors§