[−][src]Crate async_sse
Async Server Sent Event parser and encoder.
Example
use async_sse::{decode, encode, Event}; use async_std::io::Cursor; use async_std::prelude::*; #[async_std::main] async fn main() -> http_types::Result<()> { let buf = Cursor::new(vec![]); // Encode messages to an AsyncWrite. let mut encoder = encode(buf); encoder.send("cat", b"chashu", None).await?; let mut buf = encoder.into_writer(); buf.set_position(0); // Decode messages from an AsyncRead. let mut reader = decode(buf); let event = reader.next().await.unwrap()?; // Match and handle the event Ok(()) }
References
Structs
Decoder | An SSE protocol decoder. |
Encoder | An SSE protocol encoder. |
Message | A data event. |
Enums
Event | The kind of event sent. |
Functions
decode | Decode a new incoming SSE connection. |
encode | Encode a new SSE connection. |