pub mod json;
use thiserror::Error;
use varpulis_core::Event;
#[derive(Debug, Error)]
pub enum ConverterError {
#[error("deserialization failed: {0}")]
DeserializeFailed(String),
#[error("serialization failed: {0}")]
SerializeFailed(String),
#[error("unsupported format: {0}")]
UnsupportedFormat(String),
#[error("initialization failed: {0}")]
InitFailed(String),
}
pub trait Converter: Send + Sync {
fn name(&self) -> &str;
fn deserialize(&self, event_type: &str, payload: &[u8]) -> Result<Vec<Event>, ConverterError>;
fn serialize(&self, event: &Event) -> Result<Vec<u8>, ConverterError>;
fn init(&mut self) -> Result<(), ConverterError> {
Ok(())
}
fn shutdown(&mut self) -> Result<(), ConverterError> {
Ok(())
}
}