Skip to main content

VecModel

Struct VecModel 

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

A shared UI-thread model with separately tracked row and length reads. Cloning the handle shares its data and subscriptions.

Implementations§

Source§

impl<T> VecModel<T>

Source

pub fn row_key(&self, index: usize) -> Option<RowKey>

A stable identity that survives edits, inserts, removes of other rows, and sorting.

Source

pub fn row_index(&self, key: RowKey) -> Option<usize>

Find a record’s current index by its stable identity.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn push(&self, value: T)

Source

pub fn insert(&self, index: usize, value: T) -> bool

Insert at a model index. An index beyond the end leaves the model unchanged.

Source

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

Source

pub fn sort_by(&self, compare: impl FnMut(&T, &T) -> Comparison) -> bool

Stably reorder rows, retaining their keys and delegate lifetimes.

Source§

impl<T: Clone> VecModel<T>

Source

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

Source

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

Source§

impl<T: PartialEq> VecModel<T>

Source

pub fn set_row_if_current( &self, index: usize, key: RowKey, expected: &T, value: T, ) -> bool

Commit a value against the row and value observed by an editor.

Source

pub fn update_row_if_key( &self, index: usize, key: RowKey, update: impl FnOnce(&T) -> Option<T>, ) -> bool

Update an identified record from its latest value. Returning None declines the edit.

Source

pub fn set_row(&self, index: usize, value: T) -> bool

Replace one row. Returns false for an invalid index or equal value.

Source

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

Compare the current values, independently of handle identity.

Trait Implementations§

Source§

impl<T> Clone for VecModel<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> Default for VecModel<T>

Source§

fn default() -> Self

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

impl<T> Eq for VecModel<T>

Source§

impl<T> From<Vec<T>> for VecModel<T>

Source§

fn from(rows: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl From<VecModel<String>> for Value

Source§

fn from(model: VecModel<String>) -> Self

Converts to this type from the input type.
Source§

impl<T> PartialEq for VecModel<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 VecModel<T>

§

impl<T> !Send for VecModel<T>

§

impl<T> !Sync for VecModel<T>

§

impl<T> !UnwindSafe for VecModel<T>

§

impl<T> Forget for VecModel<T>

§

impl<T> Freeze for VecModel<T>
where Rc<ModelData<T>>: Freeze,

§

impl<T> Move for VecModel<T>

§

impl<T> Unpin for VecModel<T>
where Rc<ModelData<T>>: Unpin,

§

impl<T> UnsafeUnpin for VecModel<T>
where Rc<ModelData<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> AnyEq for T
where T: Any + PartialEq,

Source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

Source§

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

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.