pub struct Slot<T>(_);
Methods from Deref<Target = 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§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Slot<T>
impl<T> Send for Slot<T>
impl<T> Sync for Slot<T>
impl<T> Unpin for Slot<T>where T: Unpin,
impl<T> !UnwindSafe for Slot<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