pub struct BehaviorCollection(/* private fields */);Expand description
Represents a collection of IBehaviors with a shared
associated_object.
The collection is a notifying list of objects (FerroList<FerroObject>); every item must be
a behavior. It is a reference object: clones refer to the same collection and compare by
identity.
Implementations§
Source§impl BehaviorCollection
impl BehaviorCollection
Sourcepub fn new() -> Self
pub fn new() -> Self
Initializes a new instance of the BehaviorCollection class.
Sourcepub fn list(&self) -> &FerroList<Ref<FerroObject>>
pub fn list(&self) -> &FerroList<Ref<FerroObject>>
The list of the collection.
Sourcepub fn associated_object(&self) -> Option<Ref<FerroObject>>
pub fn associated_object(&self) -> Option<Ref<FerroObject>>
Gets the object to which the BehaviorCollection is attached.
Sourcepub fn attach(&self, associated_object: impl Into<Nullable<FerroObject>>)
pub fn attach(&self, associated_object: impl Into<Nullable<FerroObject>>)
Attaches the collection of behaviors to the specified object.
§Panics
Panics if the BehaviorCollection is already attached to a different object.
Sourcepub fn detach(&self)
pub fn detach(&self)
Detaches the collection of behaviors from the
associated_object.
Methods from Deref<Target = FerroList<Ref<FerroObject>>>§
Sourcepub fn add_collection_changed(
&self,
handler: Rc<dyn for<'a> Fn(&NotifyCollectionChangedEventArgs<'a, T>)>,
) -> u64
pub fn add_collection_changed( &self, handler: Rc<dyn for<'a> Fn(&NotifyCollectionChangedEventArgs<'a, T>)>, ) -> u64
Subscribes to changes. Returns a token for
remove_collection_changed.
Sourcepub fn remove_collection_changed(&self, token: u64) -> bool
pub fn remove_collection_changed(&self, token: u64) -> bool
Unsubscribes a handler.
Sourcepub fn has_collection_changed_subscribers(&self) -> bool
pub fn has_collection_changed_subscribers(&self) -> bool
Whether anything is subscribed to changes, typed or untyped.
pub fn is_empty(&self) -> bool
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
The number of items the list can hold before its storage grows.
Sourcepub fn set_capacity(&self, capacity: usize)
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.
Sourcepub fn reset_behavior(&self) -> ResetBehavior
pub fn reset_behavior(&self) -> ResetBehavior
The reset behavior of the list.
pub fn set_reset_behavior(&self, value: ResetBehavior)
Sourcepub fn validate(&self) -> Option<Rc<dyn Fn(&T)>>where
T: 'static,
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.
Sourcepub fn set_validate(&self, value: Option<Rc<dyn Fn(&T)>>)where
T: 'static,
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.
Sourcepub fn validator(&self) -> Option<Rc<dyn IFerroListItemValidator<T>>>where
T: 'static,
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.
pub fn set_validator(&self, value: Option<Rc<dyn IFerroListItemValidator<T>>>)
Sourcepub fn snapshot(&self) -> Rc<Vec<T>>
pub fn snapshot(&self) -> Rc<Vec<T>>
A snapshot of the items. It stays valid and unchanged if the list is modified.
Sourcepub fn add_range(&self, items: impl IntoIterator<Item = T>)
pub fn add_range(&self, items: impl IntoIterator<Item = T>)
Adds multiple items to the collection.
Sourcepub fn insert_range(&self, index: usize, items: impl IntoIterator<Item = T>)
pub fn insert_range(&self, index: usize, items: impl IntoIterator<Item = T>)
Inserts multiple items at the specified index.
Sourcepub fn move_range(&self, old_index: usize, count: usize, new_index: usize)
pub fn move_range(&self, old_index: usize, count: usize, new_index: usize)
Moves multiple items to a new index.
Sourcepub fn remove_range(&self, index: usize, count: usize)
pub fn remove_range(&self, index: usize, count: usize)
Removes a range of elements from the collection.
Sourcepub fn copy_to(&self, array: &mut [T], array_index: usize)
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.
Sourcepub fn get_range(&self, index: usize, count: usize) -> Vec<T>
pub fn get_range(&self, index: usize, count: usize) -> Vec<T>
Gets a range of items from the collection.
Sourcepub fn ensure_capacity(&self, capacity: usize)
pub fn ensure_capacity(&self, capacity: usize)
Ensures that the capacity of the list is at least capacity.
Sourcepub fn remove(&self, item: &T) -> bool
pub fn remove(&self, item: &T) -> bool
Removes an item from the collection. Returns true if it was present.
Sourcepub fn remove_all(&self, items: impl IntoIterator<Item = T>)
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 Clone for BehaviorCollection
impl Clone for BehaviorCollection
Source§impl Debug for BehaviorCollection
impl Debug for BehaviorCollection
Source§impl Default for BehaviorCollection
impl Default for BehaviorCollection
Source§impl Deref for BehaviorCollection
impl Deref for BehaviorCollection
Source§impl MarkupTyped for BehaviorCollection
impl MarkupTyped for BehaviorCollection
Source§const MARKUP: &'static MarkupType
const MARKUP: &'static MarkupType
Auto Trait Implementations§
impl !RefUnwindSafe for BehaviorCollection
impl !Send for BehaviorCollection
impl !Sync for BehaviorCollection
impl !UnwindSafe for BehaviorCollection
impl Freeze for BehaviorCollection
impl Unpin for BehaviorCollection
impl UnsafeUnpin for BehaviorCollection
Blanket Implementations§
Source§impl<T> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more