Skip to main content

FerroList

Struct FerroList 

Source
pub struct FerroList<T>(/* private fields */);
Expand description

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.

Implementations§

Source§

impl<T> FerroList<T>

Source

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

Whether two handles refer to the same list.

Source§

impl<T: Clone> FerroList<T>

Source

pub fn new() -> Self

Creates an empty list.

Source

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

Creates a list with initial items.

Source

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

Subscribes to changes. Returns a token for remove_collection_changed.

Source

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

Unsubscribes a handler.

Source

pub fn has_collection_changed_subscribers(&self) -> bool

Whether anything is subscribed to changes, typed or untyped.

Source

pub fn count(&self) -> usize

The number of items in the list.

Source

pub fn is_empty(&self) -> bool

Source

pub fn capacity(&self) -> usize

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

Source

pub fn set_capacity(&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

pub fn reset_behavior(&self) -> ResetBehavior

The reset behavior of the list.

Source

pub fn set_reset_behavior(&self, value: ResetBehavior)

Source

pub fn validate(&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

pub fn set_validate(&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

pub fn validator(&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

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

Source

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

The item at index. Panics if out of range.

Source

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

The item at index, if in range.

Source

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

Replaces the item at index.

Source

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

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

Source

pub fn to_vec(&self) -> Vec<T>

Copies the items into a vector.

Source

pub fn for_each(&self, f: impl FnMut(&T))

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

Source

pub fn add(&self, item: T)

Adds an item to the collection.

Source

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

Adds multiple items to the collection.

Source

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

Inserts an item at the specified index.

Source

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

Inserts multiple items at the specified index.

Source

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

Moves an item to a new index.

Source

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

Moves multiple items to a new index.

Source

pub fn remove_at(&self, index: usize)

Removes the item at the specified index.

Source

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

Removes a range of elements from the collection.

Source

pub fn clear(&self)

Removes all items from the collection.

Source

pub fn copy_to(&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

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

Gets a range of items from the collection.

Source

pub fn ensure_capacity(&self, capacity: usize)

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

Source§

impl<T: Clone + PartialEq> FerroList<T>

Source

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

Tests whether the collection contains an item.

Source

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

The index of an item in the collection.

Source

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

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

Source

pub fn remove_all(&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.

Trait Implementations§

Source§

impl<T> Clone for FerroList<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for FerroList<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Clone> Default for FerroList<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Clone + PartialEq> IFerroList<T> for FerroList<T>

Source§

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

Sets the element at the specified index.
Source§

fn add(&self, item: T)

Adds an item to the collection.
Source§

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

Inserts an item at the specified index.
Source§

fn remove_at(&self, index: usize)

Removes the item at the specified index.
Source§

fn clear(&self)

Removes all items from the collection.
Source§

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

Tests whether the collection contains an item.
Source§

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

The index of an item in the collection.
Source§

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

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

fn add_range(&self, items: Vec<T>)

Adds multiple items to the collection.
Source§

fn insert_range(&self, index: usize, items: Vec<T>)

Inserts multiple items at the specified index.
Source§

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

Moves an item to a new index.
Source§

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

Moves multiple items to a new index.
Source§

fn remove_all(&self, items: Vec<T>)

Removes multiple items from the collection.
Source§

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

Removes a range of elements from the collection.
Source§

impl<T: Clone> IFerroReadOnlyList<T> for FerroList<T>

Source§

fn count(&self) -> usize

The number of items in the list.
Source§

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

The item at index. Panics if out of range.
Source§

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

The items, as a snapshot that stays unchanged if the list is modified (enumeration).
Source§

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

Subscribes to changes. Returns a token for remove_collection_changed.
Source§

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

Unsubscribes a handler.
Source§

impl<T> INotifyCollectionChanged for FerroList<T>

Source§

fn collection_changed(&self) -> &Event<CollectionChange>

The event raised when the collection changes.
Source§

impl<T> INotifyPropertyChanged for FerroList<T>

Source§

fn property_changed(&self) -> &Event<str>

The event raised when a property value changes.
Source§

fn as_notify_property_changing(&self) -> Option<&dyn INotifyPropertyChanging>

The object as INotifyPropertyChanging, when it also raises the event of a property that is about to change; None by default. Read more
Source§

impl MarkupTyped for FerroList<Rc<dyn IAnimationSetter>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Rc<dyn IResourceProvider>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Ref<KeyBinding>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Rc<dyn SetterBase>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Rc<dyn IAnimation>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Rc<dyn BindingBase>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Point>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<String>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Ref<GradientStop>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Rc<dyn ITransition>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Ref<KeyFrame>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Ref<PathFigure>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Ref<PathSegment>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Ref<Drawing>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Ref<Transform>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Ref<Geometry>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<FontFeature>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for FerroList<Ref<TextDecoration>>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl<T> PartialEq for FerroList<T>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: 'static> WeakEventSender for FerroList<T>

Source§

type Weak = WeakFerroList<T>

The weak form of the handle.
Source§

fn downgrade_sender(&self) -> WeakFerroList<T>

Source§

fn upgrade_sender(weak: &WeakFerroList<T>) -> Option<Self>

Source§

fn sender_address(&self) -> usize

The address of the object the handle refers to.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for FerroList<T>

§

impl<T> !Send for FerroList<T>

§

impl<T> !Sync for FerroList<T>

§

impl<T> !UnwindSafe for FerroList<T>

§

impl<T> Freeze for FerroList<T>
where Rc<FerroListData<T>>: Freeze,

§

impl<T> Unpin for FerroList<T>
where Rc<FerroListData<T>>: Unpin,

§

impl<T> UnsafeUnpin for FerroList<T>
where Rc<FerroListData<T>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyValue for T
where T: PartialEq + 'static,

Source§

fn any_value_as_any(&self) -> &(dyn Any + 'static)

Source§

fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool

Source§

fn any_value_type_name(&self) -> &'static str

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PropertyValue for T
where T: Clone + PartialEq + 'static,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.