Skip to main content

EventStreamFormatter

Trait EventStreamFormatter 

Source
pub trait EventStreamFormatter {
    // Required methods
    fn content_type(&self) -> &'static str;
    fn encode(&self, event: &Event) -> Result<Vec<u8>>;
}
Expand description

Turns events into the bytes a transport puts on the wire.

Object-safe, so a server can pick a formatter once per connection and store it as Box<dyn EventStreamFormatter>.

Required Methods§

Source

fn content_type(&self) -> &'static str

The Content-Type to answer with.

Source

fn encode(&self, event: &Event) -> Result<Vec<u8>>

Encodes one event, framing included.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§