ferroui_dynamic_data/aggregation/aggregate_item.rs
1//! `AggregateItem<TObject>` (`Aggregation/AggregateItem.cs`).
2
3use super::AggregateType;
4
5/// An item that is added to or removed from a continuous aggregation (`AggregateItem<TObject>`).
6///
7/// Equality and hashing are those of the type and the item (upstream's `IEquatable`).
8#[derive(Clone, Debug, PartialEq, Eq, Hash)]
9pub struct AggregateItem<T> {
10 aggregate_type: AggregateType,
11 item: T,
12}
13
14impl<T> AggregateItem<T> {
15 /// An item of `aggregate_type` (`AggregateItem(AggregateType, TObject)`).
16 pub fn new(aggregate_type: AggregateType, item: T) -> Self {
17 Self { aggregate_type, item }
18 }
19
20 /// Whether the item is added or removed (`Type`).
21 pub fn aggregate_type(&self) -> AggregateType {
22 self.aggregate_type
23 }
24
25 /// The item (`Item`).
26 pub fn item(&self) -> &T {
27 &self.item
28 }
29
30 /// The item, taken out.
31 pub fn into_item(self) -> T {
32 self.item
33 }
34}