Skip to main content

MediaCollection

Struct MediaCollection 

Source
pub struct MediaCollection<T: Clone + 'static> { /* private fields */ }
Expand description

A shared, observable list. Cloning the handle shares the list; equality is by identity.

Implementations§

Source§

impl<T: Clone + 'static> MediaCollection<T>

Source

pub fn new() -> Self

Creates an empty list.

Source

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

Creates a list holding items.

Source

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

Wraps an existing list.

Source

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

The underlying list.

Source

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

Whether both handles refer to the same list.

Source

pub fn reset_behavior(&self) -> ResetBehavior

The action notified when the list is cleared.

Source

pub fn set_reset_behavior(&self, value: ResetBehavior)

Sets the action notified when the list is cleared.

Source

pub fn len(&self) -> usize

The number of items.

Source

pub fn is_empty(&self) -> bool

Source

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

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

Source

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

A copy of the items.

Source

pub fn iter(&self) -> IntoIter<T> ⓘ

Iterates over a snapshot of the items.

Source

pub fn add(&self, item: T)

Appends an item.

Source

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

Appends several items with a single notification.

Source

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

Inserts an item at index.

Source

pub fn remove_at(&self, index: usize)

Removes the item at index.

Source

pub fn clear(&self)

Removes all items.

Source

pub fn collection_changed( &self, handler: impl for<'a, 'b> Fn(&'a NotifyCollectionChangedEventArgs<'b, T>) + 'static, ) -> Rc<dyn IDisposable>

Subscribes to changes of the list. Disposing the returned handle unsubscribes.

Source

pub fn for_each_item( &self, added: impl Fn(usize, &T) + 'static, removed: impl Fn(usize, &T) + 'static, reset: impl Fn() + 'static, ) -> Rc<dyn IDisposable>

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.

Source§

impl<T: Clone + PartialEq + 'static> MediaCollection<T>

Source

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

Replaces the item at index.

Source

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

Whether the list contains item.

Source

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

The index of the first occurrence of item.

Source

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

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

Trait Implementations§

Source§

impl<T: Clone + 'static> Clone for MediaCollection<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: Clone + Debug + 'static> Debug for MediaCollection<T>

Source§

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

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

impl<T: Clone + 'static> Default for MediaCollection<T>

Source§

fn default() -> Self

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

impl<T: Clone + 'static> FromIterator<T> for MediaCollection<T>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl MarkupTyped for MediaCollection<f64>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl<T: Clone + 'static> PartialEq for MediaCollection<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

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for MediaCollection<T>

§

impl<T> !Send for MediaCollection<T>

§

impl<T> !Sync for MediaCollection<T>

§

impl<T> !UnwindSafe for MediaCollection<T>

§

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

§

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

§

impl<T> UnsafeUnpin for MediaCollection<T>

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.