Skip to main content

ferroui_system/collections/specialized/
i_notify_collection_changed.rs

1//! `System.Collections.Specialized.INotifyCollectionChanged`: the change notification of a
2//! collection, and the untyped description of a change that untyped listeners receive.
3
4use super::NotifyCollectionChangedAction;
5use crate::events::Event;
6
7/// An untyped description of a change to a collection, as seen by bindings
8/// with an indexer in their path.
9///
10/// Indexes are `-1` when not applicable to the action.
11#[derive(Clone, Copy, Debug, PartialEq, Eq)]
12pub struct CollectionChange {
13    pub action: NotifyCollectionChangedAction,
14    pub new_starting_index: i32,
15    pub new_count: usize,
16    pub old_starting_index: i32,
17    pub old_count: usize,
18}
19
20/// Notifies clients of changes to a collection, such as when items are added
21/// and removed or the whole collection is reset.
22pub trait INotifyCollectionChanged {
23    /// The event raised when the collection changes.
24    fn collection_changed(&self) -> &Event<CollectionChange>;
25}