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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/// Tumbling-windowed operator.
pub mod tumbling;

/// [`Facet`] combinator of ticked operators.
pub mod facet;

/// [`Map`] combinator of ticked operators.
pub mod map;

#[cfg(feature = "array-vec")]
/// [`Array`] combinator of ticked operators.
pub mod array;

/// [`Tuple`] combinator of ticked operators.
pub mod tuple;

use crate::operator::then::Then;
use crate::{Operator, OperatorExt, Tickable};
#[cfg(feature = "array-vec")]
pub use array::{array_t, Array};
#[cfg(feature = "std")]
pub use facet::{facet_map_t, FacetMap};
pub use facet::{facet_t, Facet};
pub use map::{map_t, Map};
pub use tumbling::{
    cached, queue::QueueCapAtLeast, Cached, CachedOperation, TumblingOperation, TumblingOperator,
    TumblingQueue,
};
#[cfg(feature = "std")]
pub use tumbling::{shared, SharedMap};
pub use tuple::{tuple_t, Tuple};

/// Ticked operator.
pub trait TickedOperatorExt<I: Tickable>: Operator<I>
where
    <Self as Operator<I>>::Output: Tickable,
{
    /// Combine with the other tick operator to get a facet operator that keep the [`Tick`] unchanged.
    ///
    /// [`Tick`]: crate::Tick
    fn facet_t<P2: Operator<I>>(self, other: P2) -> Facet<I, Self, P2>
    where
        Self: Sized,
        <P2 as Operator<I>>::Output: Tickable,
    {
        facet_t(self, other)
    }

    /// Transform the value of the output but keep the [`Tick`] unchanged.
    ///
    /// [`Tick`]: crate::Tick
    fn map_t<O, F>(self, f: F) -> Then<I, Self, Map<F>>
    where
        Self: Sized,
        F: FnMut(<Self::Output as Tickable>::Value) -> O,
    {
        self.then(map_t(f))
    }
}

impl<P, I: Tickable> TickedOperatorExt<I> for P
where
    P: Operator<I>,
    <P as Operator<I>>::Output: Tickable,
{
}