uhttp_sse 0.5.1

Zero-copy, zero-allocation HTTP Server-Sent Events protocol
Documentation
  • Coverage
  • 100%
    9 out of 9 items documented1 out of 9 items with examples
  • Size
  • Source code size: 8.99 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.7 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • kchmck/uhttp_sse.rs
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kchmck

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.

Example

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!(sse.data().unwrap(), "abc").unwrap();
    write!(sse.data().unwrap(), "{}", 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");