FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    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.

    View source

    Members

    new

    fn new() -> Self
    

    Creates an empty list.

    Source

    from_items

    fn from_items(items: impl IntoIterator<Item = T>) -> Self
    

    Creates a list holding items.

    Source

    from_list

    fn from_list(list: Rc<FerroList<T>>) -> Self
    

    Wraps an existing list.

    Source

    list

    fn list(self: &Self) -> &Rc<FerroList<T>>
    

    The underlying list.

    Source

    ptr_eq

    fn ptr_eq(self: &Self, other: &Self) -> bool
    

    Whether both handles refer to the same list.

    Source

    reset_behavior

    fn reset_behavior(self: &Self) -> ResetBehavior
    

    The action notified when the list is cleared.

    Source

    set_reset_behavior

    fn set_reset_behavior(self: &Self, value: ResetBehavior)
    

    Sets the action notified when the list is cleared.

    Source

    len

    fn len(self: &Self) -> usize
    

    The number of items.

    Source

    is_empty

    fn is_empty(self: &Self) -> bool
    

    Source

    get

    fn get(self: &Self, index: usize) -> T
    

    The item at index. Panics if the index is out of range.

    Source

    to_vec

    fn to_vec(self: &Self) -> Vec<T>
    

    A copy of the items.

    Source

    iter

    fn iter(self: &Self) -> std::vec::IntoIter<T>
    

    Iterates over a snapshot of the items.

    Source

    add

    fn add(self: &Self, item: T)
    

    Appends an item.

    Source

    add_range

    fn add_range(self: &Self, items: impl IntoIterator<Item = T>)
    

    Appends several items with a single notification.

    Source

    insert

    fn insert(self: &Self, index: usize, item: T)
    

    Inserts an item at index.

    Source

    remove_at

    fn remove_at(self: &Self, index: usize)
    

    Removes the item at index.

    Source

    clear

    fn clear(self: &Self)
    

    Removes all items.

    Source

    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.

    Source

    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.

    Source

    set

    fn set(self: &Self, index: usize, value: T)
    

    Replaces the item at index.

    Source

    contains

    fn contains(self: &Self, item: &T) -> bool
    

    Whether the list contains item.

    Source

    index_of

    fn index_of(self: &Self, item: &T) -> Option<usize>
    

    The index of the first occurrence of item.

    Source

    remove

    fn remove(self: &Self, item: &T) -> bool
    

    Removes the first occurrence of item; returns whether it was found.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • PropertyValue
    • AnyValue
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ErasedDestructor
    • IntoEither
    • Clone
    • PartialEq
    • Default
    • Debug
    • FromIterator<T>
    • MarkupTyped

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.