FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    FerroList

    struct · ferroui-base · v0.5.0

    struct FerroList<T>
    

    A notifying list.

    Enumeration works on a snapshot, so the list may be modified from within an enumeration or a change notification. The snapshot shares storage with the list and is only copied if the list is modified while it is alive.

    The list is a reference object: the value is a shared handle, clones refer to the same list and handles compare by identity.

    View source

    Members

    ptr_eq

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

    Whether two handles refer to the same list.

    Source

    new

    fn new() -> Self
    

    Creates an empty list.

    Source

    from_items

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

    Creates a list with initial items.

    Source

    add_collection_changed

    fn add_collection_changed(self: &Self, handler: Rc<CollectionChangedHandler<T>>) -> u64
    

    Subscribes to changes. Returns a token for remove_collection_changed.

    Source

    remove_collection_changed

    fn remove_collection_changed(self: &Self, token: u64) -> bool
    

    Unsubscribes a handler.

    Source

    has_collection_changed_subscribers

    fn has_collection_changed_subscribers(self: &Self) -> bool
    

    Whether anything is subscribed to changes, typed or untyped.

    Source

    count

    fn count(self: &Self) -> usize
    

    The number of items in the list.

    Source

    is_empty

    fn is_empty(self: &Self) -> bool
    

    Source

    capacity

    fn capacity(self: &Self) -> usize
    

    The number of items the list can hold before its storage grows.

    Source

    set_capacity

    fn set_capacity(self: &Self, capacity: usize)
    

    Sets the number of items the list can hold before its storage grows.

    Panics

    Panics if capacity is less than the number of items, as the managed original throws.

    Source

    reset_behavior

    fn reset_behavior(self: &Self) -> ResetBehavior
    

    The reset behavior of the list.

    Source

    set_reset_behavior

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

    Source

    validate

    fn validate(self: &Self) -> Option<Rc<dyn Fn(&T) -> ()>>
    where T: 'static
    

    The validation routine that is invoked for every item before it is added to the list.

    Source

    set_validate

    fn set_validate(self: &Self, value: Option<Rc<dyn Fn(&T) -> ()>>)
    where T: 'static
    

    Sets a validation routine that is invoked for every item before it is added to the list; it rejects an item by panicking.

    Source

    validator

    fn validator(self: &Self) -> Option<Rc<dyn IFerroListItemValidator<T>>>
    where T: 'static
    

    The validator that is invoked for every item before it is added to the list.

    Source

    set_validator

    fn set_validator(self: &Self, value: Option<Rc<dyn IFerroListItemValidator<T>>>)
    

    Source

    get

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

    The item at index. Panics if out of range.

    Source

    try_get

    fn try_get(self: &Self, index: usize) -> Option<T>
    

    The item at index, if in range.

    Source

    set

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

    Replaces the item at index.

    Source

    snapshot

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

    A snapshot of the items. It stays valid and unchanged if the list is modified.

    Source

    to_vec

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

    Copies the items into a vector.

    Source

    for_each

    fn for_each(self: &Self, f: impl FnMut(&T) -> ())
    

    Calls f for each item of a snapshot of the list.

    Source

    add

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

    Adds an item to the collection.

    Source

    add_range

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

    Adds multiple items to the collection.

    Source

    insert

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

    Inserts an item at the specified index.

    Source

    insert_range

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

    Inserts multiple items at the specified index.

    Source

    move_item

    fn move_item(self: &Self, old_index: usize, new_index: usize)
    

    Moves an item to a new index.

    Source

    move_range

    fn move_range(self: &Self, old_index: usize, count: usize, new_index: usize)
    

    Moves multiple items to a new index.

    Source

    remove_at

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

    Removes the item at the specified index.

    Source

    remove_range

    fn remove_range(self: &Self, index: usize, count: usize)
    

    Removes a range of elements from the collection.

    Source

    clear

    fn clear(self: &Self)
    

    Removes all items from the collection.

    Source

    copy_to

    fn copy_to(self: &Self, array: &mut [T], array_index: usize)
    

    Copies the items into array, starting at array_index.

    Panics

    Panics if array is too small, as the managed original throws.

    Source

    get_range

    fn get_range(self: &Self, index: usize, count: usize) -> Vec<T>
    

    Gets a range of items from the collection.

    Source

    ensure_capacity

    fn ensure_capacity(self: &Self, capacity: usize)
    

    Ensures that the capacity of the list is at least capacity.

    Source

    contains

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

    Tests whether the collection contains an item.

    Source

    index_of

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

    The index of an item in the collection.

    Source

    remove

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

    Removes an item from the collection. Returns true if it was present.

    Source

    remove_all

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

    Removes multiple items from the collection.

    Each run of adjacent items that are removed is notified as one removal, from the end of the list to its start.

    Source

    Trait implementations

    Availability

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