Crate uhttp_sse [] [src]

This crate provides a zero-copy, zero-allocation implementation of the Server-Sent Events (SSE) protocol for streaming events from an HTTP server.

The events can be written directly to a TcpStream or any other object that implements Write.


use uhttp_sse::SseMessage;
use std::io::Write;

let mut buf = [0; 31];

    let mut sse = SseMessage::new(&mut buf[..]);
    write!(sse.event().unwrap(), "ping").unwrap();
    write!(, "abc").unwrap();
    write!(, "{}", 1337).unwrap();

// This would result in the "ping" event listener being triggered with the data
// payload "abc1337".
assert_eq!(&buf[..], b"event:ping\ndata:abc\ndata:1337\n\n");



A field in an SSE message.


An SSE message.