raphtory_api/core/entities/properties/
tprop.rs

1use crate::core::{
2    entities::properties::prop::Prop,
3    storage::timeindex::{AsTime, TimeIndexEntry},
4};
5use std::ops::Range;
6
7pub trait TPropOps<'a>: Clone + Send + Sync + Sized + 'a {
8    fn active(&self, w: Range<TimeIndexEntry>) -> bool {
9        self.clone().iter_window(w).next().is_some()
10    }
11
12    /// Is there any event in this window
13    fn active_t(&self, w: Range<i64>) -> bool {
14        self.clone().iter_window_t(w).next().is_some()
15    }
16
17    fn last_before(&self, t: TimeIndexEntry) -> Option<(TimeIndexEntry, Prop)> {
18        self.clone().iter_window(TimeIndexEntry::MIN..t).next_back()
19    }
20
21    fn iter(self) -> impl DoubleEndedIterator<Item = (TimeIndexEntry, Prop)> + Send + Sync + 'a;
22
23    fn iter_t(self) -> impl DoubleEndedIterator<Item = (i64, Prop)> + Send + Sync + 'a {
24        self.iter().map(|(t, v)| (t.t(), v))
25    }
26
27    fn iter_window(
28        self,
29        r: Range<TimeIndexEntry>,
30    ) -> impl DoubleEndedIterator<Item = (TimeIndexEntry, Prop)> + Send + Sync + 'a;
31
32    fn iter_window_t(
33        self,
34        r: Range<i64>,
35    ) -> impl DoubleEndedIterator<Item = (i64, Prop)> + Send + Sync + 'a {
36        self.iter_window(TimeIndexEntry::range(r))
37            .map(|(t, v)| (t.t(), v))
38    }
39
40    fn iter_window_te(
41        self,
42        r: Range<TimeIndexEntry>,
43    ) -> impl DoubleEndedIterator<Item = (i64, Prop)> + Send + Sync + 'a {
44        self.iter_window(r).map(|(t, v)| (t.t(), v))
45    }
46
47    fn at(&self, ti: &TimeIndexEntry) -> Option<Prop>;
48}