Skip to main content

EventToBytes

Trait EventToBytes 

Source
pub trait EventToBytes {
    // Required methods
    fn binary_size(&self) -> usize;
    fn write<W: Write>(&self, writer: W) -> Result<()>;
}
Expand description

Trait for converting events to a byte representation.

This trait is implemented for types that can be serialized into a byte array representing an event. It has the same methods as crate::events::payload::PayloadToBytes, but is a separate trait to disallow serializing raw payloads that are not events by mistake.

Required Methods§

Source

fn binary_size(&self) -> usize

Get the binary size of the event.

Source

fn write<W: Write>(&self, writer: W) -> Result<()>

Write the event to a writer implementing [std::io::Write].

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl EventToBytes for &[u8]

Source§

fn binary_size(&self) -> usize

Source§

fn write<W: Write>(&self, writer: W) -> Result<()>

Implementors§