springql_foreign_service/source/
source_input.rs1pub mod timed_stream;
4
5use self::timed_stream::TimedStream;
6use anyhow::Result;
7use std::collections::VecDeque;
8
9#[derive(Debug)]
10pub enum ForeignSourceInput {
11 FifoBatch(VecDeque<serde_json::Value>),
12 TimedStream(TimedStream),
13}
14
15impl ForeignSourceInput {
16 pub fn new_fifo_batch(input: Vec<serde_json::Value>) -> Self {
17 let v = input.into_iter().collect();
18 Self::FifoBatch(v)
19 }
20
21 pub fn new_timed_stream(ts: TimedStream) -> Self {
22 Self::TimedStream(ts)
23 }
24}
25
26impl Iterator for ForeignSourceInput {
27 type Item = Result<serde_json::Value>;
28
29 fn next(&mut self) -> Option<Self::Item> {
30 match self {
31 ForeignSourceInput::FifoBatch(batch) => batch.pop_front().map(Ok),
32 ForeignSourceInput::TimedStream(timed_stream) => timed_stream.next(),
33 }
34 }
35}