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
#![allow(missing_docs)]

use serde::{Deserialize, Serialize};

use crate::{traits::Coalesce, Aggregate};

use super::{Aggregators, Counter};

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct MapStructContext {
    pub count: Counter,
    #[serde(skip)]
    pub other_aggregators: Aggregators<[String]>,
}
impl Aggregate<[String]> for MapStructContext {
    fn aggregate(&mut self, value: &[String]) {
        self.count.aggregate(value);
    }
}
impl Coalesce for MapStructContext {
    fn coalesce(&mut self, other: Self)
    where
        Self: Sized,
    {
        self.count.coalesce(other.count);
    }
}
impl PartialEq for MapStructContext {
    /// NOTE: [MapStructContext]'s [PartialEq] implementation ignores the `other_aggregators`
    /// provided by the user of the library.
    fn eq(&self, other: &Self) -> bool {
        self.count == other.count
    }
}