es4forensics/ecs/
timeline_object.rs1use serde_json::Value;
2
3use crate::timestamp::Timestamp;
4
5use super::ecs_builder::EcsBuilder;
6
7pub trait TimelineObject: IntoIterator<Item = anyhow::Result<EcsBuilder>> {
8 fn into_values(self) -> Box<dyn Iterator<Item = Value>>
9 where
10 Self: Sized,
11 <Self as std::iter::IntoIterator>::IntoIter: 'static,
12 {
13 let res = self.into_iter().filter_map(|b| b.ok()).map(|b| {
14 let (_, v) = b.into();
15 v
16 });
17 Box::new(res)
18 }
19
20 fn into_tuples(self) -> Box<dyn Iterator<Item = (Timestamp, Value)>>
21 where
22 Self: Sized,
23 <Self as std::iter::IntoIterator>::IntoIter: 'static,
24 {
25 let res = self
26 .into_iter()
27 .filter_map(|b| b.ok())
28 .map(EcsBuilder::into);
29 Box::new(res)
30 }
31}