MediaCollection
struct · ferroui-base · v0.5.0
struct MediaCollection<T: Clone + 'static>
A shared, observable list. Cloning the handle shares the list; equality is by identity.
Members
newfrom_itemsfrom_listlistptr_eqreset_behaviorset_reset_behaviorlenis_emptygetto_veciteraddadd_rangeinsertremove_atclearcollection_changedfor_each_itemsetcontainsindex_ofremove
new
fn new() -> Self
Creates an empty list.
from_items
fn from_items(items: impl IntoIterator<Item = T>) -> Self
Creates a list holding items.
from_list
fn from_list(list: Rc<FerroList<T>>) -> Self
Wraps an existing list.
list
fn list(self: &Self) -> &Rc<FerroList<T>>
The underlying list.
ptr_eq
fn ptr_eq(self: &Self, other: &Self) -> bool
Whether both handles refer to the same list.
reset_behavior
fn reset_behavior(self: &Self) -> ResetBehavior
The action notified when the list is cleared.
set_reset_behavior
fn set_reset_behavior(self: &Self, value: ResetBehavior)
Sets the action notified when the list is cleared.
len
fn len(self: &Self) -> usize
The number of items.
is_empty
fn is_empty(self: &Self) -> bool
get
fn get(self: &Self, index: usize) -> T
The item at index. Panics if the index is out of range.
to_vec
fn to_vec(self: &Self) -> Vec<T>
A copy of the items.
iter
fn iter(self: &Self) -> std::vec::IntoIter<T>
Iterates over a snapshot of the items.
add
fn add(self: &Self, item: T)
Appends an item.
add_range
fn add_range(self: &Self, items: impl IntoIterator<Item = T>)
Appends several items with a single notification.
insert
fn insert(self: &Self, index: usize, item: T)
Inserts an item at index.
remove_at
fn remove_at(self: &Self, index: usize)
Removes the item at index.
clear
fn clear(self: &Self)
Removes all items.
collection_changed
fn collection_changed(self: &Self, handler: impl Fn(&'a NotifyCollectionChangedEventArgs<'b, T>) -> () + 'static) -> Subscription
Subscribes to changes of the list. Dropping the returned guard removes
the handler; Subscription::detach keeps it for the life of the
list.
for_each_item
fn for_each_item(self: &Self, added: impl Fn(usize, &T) -> () + 'static, removed: impl Fn(usize, &T) -> () + 'static, reset: impl Fn() -> () + 'static) -> Subscription
Invokes added for every item currently in the list and for every item
added later, removed for every item removed and reset when the list
is reset. Dropping the returned guard stops the calls for later
changes; Subscription::detach keeps them for the life of the list.
set
fn set(self: &Self, index: usize, value: T)
Replaces the item at index.
contains
fn contains(self: &Self, item: &T) -> bool
Whether the list contains item.
index_of
fn index_of(self: &Self, item: &T) -> Option<usize>
The index of the first occurrence of item.
remove
fn remove(self: &Self, item: &T) -> bool
Removes the first occurrence of item; returns whether it was found.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafePropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedErasedDestructorIntoEitherClonePartialEqDefaultDebugFromIterator<T>MarkupTyped
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.