pub trait EventStreamFormatter {
// Required methods
fn content_type(&self) -> &'static str;
fn encode(&self, event: &Event) -> Result<Vec<u8>>;
}Available on crate features
protobuf or sse only.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§
Sourcefn content_type(&self) -> &'static str
fn content_type(&self) -> &'static str
The Content-Type to answer with.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl EventStreamFormatter for ProtobufFormatter
Available on crate feature
protobuf only.impl EventStreamFormatter for SseFormatter
Available on crate feature
sse only.