rtlola_io_plugins/
inputs.rs

1#[cfg(feature = "csv_plugin")]
2pub mod csv_plugin;
3
4#[cfg(feature = "pcap_plugin")]
5pub mod pcap_plugin;
6
7#[cfg(feature = "byte_plugin")]
8pub mod byte_plugin;
9
10use std::error::Error;
11
12use rtlola_interpreter::input::{AssociatedEventFactory, EventFactory};
13use rtlola_interpreter::time::TimeRepresentation;
14
15type EventResult<MappedEvent, Time, Error> = Result<Option<(MappedEvent, Time)>, Error>;
16
17/// The main trait that has to be implemented by an input plugin
18pub trait EventSource<InputTime: TimeRepresentation> {
19    /// Type of the Event given to the monitor
20    type Record: AssociatedEventFactory;
21    /// Error type when buildin the next Event
22    type Error: Error;
23
24    /// Return the data needed by the monitor to initialize the input source.
25    fn init_data(
26        &self,
27    ) -> Result<
28        <<Self::Record as AssociatedEventFactory>::Factory as EventFactory>::CreationData,
29        Self::Error,
30    >;
31
32    /// Queries the event source for a new Record(Event) in a blocking fashion.
33    /// If there are no more records, None is returned.
34    fn next_event(&mut self) -> EventResult<Self::Record, InputTime::InnerTime, Self::Error>;
35}