Skip to main content

EventCodec

Trait EventCodec 

Source
pub trait EventCodec: Send + Sync {
    // Required methods
    fn decode(&self, bytes: &[u8]) -> Result<Value, Error>;
    fn encode(&self, event: &Value, out: &mut Vec<u8>) -> Result<(), Error>;
}
Expand description

Events as bytes: a record’s bytes to the JSON event a machine handles, and an event to bytes.

Required Methods§

Source

fn decode(&self, bytes: &[u8]) -> Result<Value, Error>

Decodes an event ({ "type": ..., ... }) from a record’s bytes.

Source

fn encode(&self, event: &Value, out: &mut Vec<u8>) -> Result<(), Error>

Appends the encoding of event to out. On an error, part of it may have been written: the caller truncates out.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§