Skip to main content

VirtualCollectionModel

Struct VirtualCollectionModel 

Source
pub struct VirtualCollectionModel<K, T> { /* private fields */ }
Expand description

Cloneable observable collection with stable keys and incremental changes.

Implementations§

Source§

impl<K, T> VirtualCollectionModel<K, T>
where K: Clone + Eq + Hash, T: Clone + PartialEq,

Source

pub fn new() -> Self

Source

pub fn named(name: impl Into<Arc<str>>) -> Self

Source

pub fn from_items( name: impl Into<Arc<str>>, items: impl IntoIterator<Item = (K, T)>, ) -> Result<Self, CollectionModelError>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn append(&self, key: K, item: T) -> Result<bool, CollectionModelError>

Source

pub fn prepend( &self, items: impl IntoIterator<Item = (K, T)>, ) -> Result<bool, CollectionModelError>

Source

pub fn remove(&self, key: K) -> Result<bool, CollectionModelError>

Source

pub fn update(&self, key: K, item: T) -> Result<bool, CollectionModelError>

Source

pub fn move_to( &self, key: K, index: usize, ) -> Result<bool, CollectionModelError>

Source

pub fn replace( &self, items: impl IntoIterator<Item = (K, T)>, ) -> Result<bool, CollectionModelError>

Source

pub fn apply( &self, change: CollectionChange<K, T>, ) -> Result<bool, CollectionModelError>

Trait Implementations§

Source§

impl<K, T> Clone for VirtualCollectionModel<K, 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<K, T> Debug for VirtualCollectionModel<K, T>
where K: Debug, T: Debug,

Source§

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

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

impl<K, T> Default for VirtualCollectionModel<K, T>
where K: Clone + Eq + Hash, T: Clone + PartialEq,

Source§

fn default() -> Self

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

impl<K, T> Observable<u64> for VirtualCollectionModel<K, T>
where K: Clone + Eq + Hash + 'static, T: Clone + PartialEq + 'static,

Source§

fn source_id(&self) -> SourceId

Source§

fn source_name(&self) -> Arc<str> ⓘ

Source§

fn get(&self) -> u64

Source§

fn subscribe(&self, observer: Observer) -> Subscription

Source§

fn read(&self, reader: &mut dyn FnMut(&T))

Call reader once with a borrow of the current value. Read more
Source§

fn value_version(&self) -> Option<u64>

A counter identifying the current value, or None if unknown. Read more
Source§

fn changed(&self) -> Changed ⓘ
where Self: Sized,

A future that resolves with the next change notification after this call. It subscribes immediately, so a change made before the first poll is not missed. It needs no particular executor.
Source§

impl<K, T> VirtualCollectionSource<K, T> for VirtualCollectionModel<K, T>
where K: Clone + Eq + Hash + 'static, T: Clone + PartialEq + 'static,

Source§

fn revision(&self) -> u64

Source§

fn keys(&self) -> Vec<K>

Source§

fn item(&self, key: &K) -> Option<T>

Source§

fn window(&self) -> CollectionWindow

Source§

fn changes_since(&self, revision: u64) -> CollectionSync<K>

Auto Trait Implementations§

§

impl<K, T> Forget for VirtualCollectionModel<K, T>

§

impl<K, T> Freeze for VirtualCollectionModel<K, T>
where Arc<RwLock<CollectionModelInner<K, T>>>: Freeze,

§

impl<K, T> Move for VirtualCollectionModel<K, T>

§

impl<K, T> RefUnwindSafe for VirtualCollectionModel<K, T>
where Arc<RwLock<CollectionModelInner<K, T>>>: RefUnwindSafe,

§

impl<K, T> Send for VirtualCollectionModel<K, T>
where Arc<RwLock<CollectionModelInner<K, T>>>: Send,

§

impl<K, T> Sync for VirtualCollectionModel<K, T>
where Arc<RwLock<CollectionModelInner<K, T>>>: Sync,

§

impl<K, T> Unpin for VirtualCollectionModel<K, T>
where Arc<RwLock<CollectionModelInner<K, T>>>: Unpin,

§

impl<K, T> UnsafeUnpin for VirtualCollectionModel<K, T>
where Arc<RwLock<CollectionModelInner<K, T>>>: UnsafeUnpin,

§

impl<K, T> UnwindSafe for VirtualCollectionModel<K, T>
where Arc<RwLock<CollectionModelInner<K, T>>>: UnwindSafe,

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> 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> 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> 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.