use serde::{Deserialize, Serialize};
use vector_lib::codecs::decoding::{DeserializerConfig, FramingConfig};
use vector_lib::config::LogNamespace;
use crate::codecs::Decoder;
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct DecodingConfig {
framing: FramingConfig,
decoding: DeserializerConfig,
log_namespace: LogNamespace,
}
impl DecodingConfig {
pub const fn new(
framing: FramingConfig,
decoding: DeserializerConfig,
log_namespace: LogNamespace,
) -> Self {
Self {
framing,
decoding,
log_namespace,
}
}
pub const fn config(&self) -> &DeserializerConfig {
&self.decoding
}
pub const fn framing(&self) -> &FramingConfig {
&self.framing
}
pub fn build(&self) -> vector_lib::Result<Decoder> {
let framer = self.framing.build();
let deserializer = self.decoding.build()?;
Ok(Decoder::new(framer, deserializer).with_log_namespace(self.log_namespace))
}
}