ferroui_base/collections/
i_ferro_read_only_list.rs1use super::{CollectionChangedHandler, FerroList};
2use crate::data::model::{INotifyCollectionChanged, INotifyPropertyChanged};
3use std::rc::Rc;
4
5pub trait IFerroReadOnlyList<T>: INotifyCollectionChanged + INotifyPropertyChanged {
12 fn count(&self) -> usize;
14
15 fn get(&self, index: usize) -> T;
17
18 fn snapshot(&self) -> Rc<Vec<T>>;
21
22 fn add_collection_changed(&self, handler: Rc<CollectionChangedHandler<T>>) -> u64;
25
26 fn remove_collection_changed(&self, token: u64) -> bool;
28}
29
30impl<T: Clone> IFerroReadOnlyList<T> for FerroList<T> {
31 fn count(&self) -> usize {
32 FerroList::count(self)
33 }
34
35 fn get(&self, index: usize) -> T {
36 FerroList::get(self, index)
37 }
38
39 fn snapshot(&self) -> Rc<Vec<T>> {
40 FerroList::snapshot(self)
41 }
42
43 fn add_collection_changed(&self, handler: Rc<CollectionChangedHandler<T>>) -> u64 {
44 FerroList::add_collection_changed(self, handler)
45 }
46
47 fn remove_collection_changed(&self, token: u64) -> bool {
48 FerroList::remove_collection_changed(self, token)
49 }
50}