pub struct Model<T> { /* private fields */ }
Implementations§
source§impl<T: 'static> Model<T>
impl<T: 'static> Model<T>
pub fn read<'a>(&self, cx: &'a AppContext) -> &'a T
pub fn read_with<'a, R, C: Context>( &self, cx: &'a C, f: impl FnOnce(&T, &AppContext) -> R ) -> C::Result<R>
sourcepub fn update<C, R>(
&self,
cx: &mut C,
update: impl FnOnce(&mut T, &mut ModelContext<'_, T>) -> R
) -> C::Result<R>where
C: Context,
pub fn update<C, R>( &self, cx: &mut C, update: impl FnOnce(&mut T, &mut ModelContext<'_, T>) -> R ) -> C::Result<R>where C: Context,
Update the entity referenced by this model with the given function.
The update function receives a context appropriate for its environment.
When updating in an AppContext
, it receives a ModelContext
.
When updating an a WindowContext
, it receives a ViewContext
.
Methods from Deref<Target = AnyModel>§
pub fn entity_id(&self) -> EntityId
pub fn entity_type(&self) -> TypeId
pub fn downgrade(&self) -> AnyWeakModel
Trait Implementations§
source§impl<T> PartialEq<Model<T>> for Model<T>
impl<T> PartialEq<Model<T>> for Model<T>
source§impl<T> PartialEq<Model<T>> for WeakModel<T>
impl<T> PartialEq<Model<T>> for WeakModel<T>
source§impl<T> PartialEq<WeakModel<T>> for Model<T>
impl<T> PartialEq<WeakModel<T>> for Model<T>
impl<T> Eq for Model<T>
impl<T> Send for Model<T>
impl<T> Sync for Model<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Model<T>
impl<T> Unpin for Model<T>where T: Unpin,
impl<T> !UnwindSafe for Model<T>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.