1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use serde_json::Value;

use crate::es4forensics::timestamp::Timestamp;

use super::ecs_builder::EcsBuilder;

pub trait TimelineObject: IntoIterator<Item = anyhow::Result<EcsBuilder>> {
    fn into_values(self) -> Box<dyn Iterator<Item = Value>>
    where
        Self: Sized,
        <Self as std::iter::IntoIterator>::IntoIter: 'static,
    {
        let res = self.into_iter().filter_map(|b| b.ok()).map(|b| {
            let (_, v) = b.into();
            v
        });
        Box::new(res)
    }

    fn into_tuples(self) -> Box<dyn Iterator<Item = (Timestamp, Value)>>
    where
        Self: Sized,
        <Self as std::iter::IntoIterator>::IntoIter: 'static,
    {
        let res = self
            .into_iter()
            .filter_map(|b| b.ok())
            .map(EcsBuilder::into);
        Box::new(res)
    }
}