Trait EventToBytes

pub trait EventToBytes {
    // Required methods
    fn binary_size(&self) -> usize;
    fn write<W>(&self, writer: W) -> Result<(), Error>
       where W: Write;
}
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§

fn binary_size(&self) -> usize

Get the binary size of the event.

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

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", so this trait is not object safe.

Implementations on Foreign Types§

§

impl EventToBytes for &[u8]

§

fn binary_size(&self) -> usize

§

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

Implementors§

§

impl EventToBytes for RawEvent<'_>

§

impl<T> EventToBytes for Event<T>
where T: PayloadToBytes,