saluki_core/components/decoders/
builder.rs

1#![allow(dead_code)]
2
3use async_trait::async_trait;
4use memory_accounting::MemoryBounds;
5use saluki_error::GenericError;
6
7use super::Decoder;
8use crate::{
9    components::ComponentContext,
10    data_model::{event::EventType, payload::PayloadType},
11};
12
13/// A decoder builder.
14///
15/// Decoder builders are responsible for creating instances of [`Decoder`]s, as well as describing high-level
16/// aspects of the built decoder, such as the data types allowed for input events and the outputs exposed by the
17/// decoder.
18#[async_trait]
19pub trait DecoderBuilder: MemoryBounds {
20    /// Data types allowed as input payloads to this decoder.
21    fn input_payload_type(&self) -> PayloadType;
22
23    /// Data types emitted as output events by this decoder.
24    fn output_event_type(&self) -> EventType;
25
26    /// Builds an instance of the decoder.
27    ///
28    /// # Errors
29    ///
30    /// If the decoder cannot be built for any reason, an error is returned.
31    async fn build(&self, context: ComponentContext) -> Result<Box<dyn Decoder + Send>, GenericError>;
32}