Trait PayloadToBytes

pub trait PayloadToBytes {
    // Required methods
    fn binary_size(&self) -> usize;
    fn write<W>(&self, metadata: &EventMetadata, writer: W) -> Result<(), Error>
       where W: Write;
}
Expand description

Trait for converting event payloads to bytes

Required Methods§

fn binary_size(&self) -> usize

Get the binary size of the payload

This is the size of the payload in bytes, excluding the event header. This can (and should) be used to preallocate buffers for writing the payload.

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

Write the payload 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.

Implementors§

Source§

impl<'a, P, A> PayloadToBytes for AnyPluginEvent<'a, P, A>
where for<'b> P: EventSource + ToBytes + FromBytes<'b> + Debug, A: EventSource + ToBytes + FromBytes<'a> + Debug,

Source§

impl<'a, T> PayloadToBytes for AsyncEvent<'a, T>
where T: EventSource + ToBytes,

Source§

impl<T> PayloadToBytes for PluginEvent<T>
where T: EventSource + ToBytes,