vector/sources/kubernetes_logs/transform_utils/
optional.rs1#![deny(missing_docs)]
4
5use std::pin::Pin;
6
7use futures::Stream;
8
9use crate::event::EventContainer;
10use crate::transforms::TaskTransform;
11
12#[derive(Clone, Debug)]
17pub struct Optional<T>(pub Option<T>);
18
19impl<T: TaskTransform<E>, E: EventContainer + 'static> TaskTransform<E> for Optional<T> {
20 fn transform(
21 self: Box<Self>,
22 task: Pin<Box<dyn Stream<Item = E> + Send>>,
23 ) -> Pin<Box<dyn Stream<Item = E> + Send>>
24 where
25 Self: 'static,
26 {
27 match self.0 {
28 Some(val) => Box::new(val).transform(task),
29 None => task,
30 }
31 }
32}