pub struct WeakEntity<T> { /* private fields */ }Expand description
A weak reference to a entity of the given type.
Implementations§
Source§impl<T: 'static> WeakEntity<T>
impl<T: 'static> WeakEntity<T>
Sourcepub fn upgrade(&self) -> Option<Entity<T>>
pub fn upgrade(&self) -> Option<Entity<T>>
Upgrade this weak entity reference into a strong entity reference
Sourcepub fn update<C, R>(
&self,
cx: &mut C,
update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R,
) -> Result<R>
pub fn update<C, R>( &self, cx: &mut C, update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R, ) -> Result<R>
Updates the entity referenced by this handle with the given function if the referenced entity still exists. Returns an error if the entity has been released.
Sourcepub fn update_in<C, R>(
&self,
cx: &mut C,
update: impl FnOnce(&mut T, &mut Window, &mut Context<'_, T>) -> R,
) -> Result<R>
pub fn update_in<C, R>( &self, cx: &mut C, update: impl FnOnce(&mut T, &mut Window, &mut Context<'_, T>) -> R, ) -> Result<R>
Updates the entity referenced by this handle with the given function if the referenced entity still exists, within a visual context that has a window. Returns an error if the entity has been released.
Sourcepub fn read_with<C, R>(
&self,
cx: &C,
read: impl FnOnce(&T, &App) -> R,
) -> Result<R>
pub fn read_with<C, R>( &self, cx: &C, read: impl FnOnce(&T, &App) -> R, ) -> Result<R>
Reads the entity referenced by this handle with the given function if the referenced entity still exists. Returns an error if the entity has been released.
Sourcepub fn new_invalid() -> Self
pub fn new_invalid() -> Self
Create a new weak entity that can never be upgraded.
Methods from Deref<Target = AnyWeakEntity>§
Sourcepub fn is_upgradable(&self) -> bool
pub fn is_upgradable(&self) -> bool
Check if this weak handle can be upgraded, or if the entity has already been dropped
Trait Implementations§
Source§impl<T> Clone for WeakEntity<T>
impl<T> Clone for WeakEntity<T>
Source§impl<T> Debug for WeakEntity<T>
impl<T> Debug for WeakEntity<T>
Source§impl<T> Deref for WeakEntity<T>
impl<T> Deref for WeakEntity<T>
Source§impl<T> DerefMut for WeakEntity<T>
impl<T> DerefMut for WeakEntity<T>
Source§impl<T> From<WeakEntity<T>> for AnyWeakEntity
impl<T> From<WeakEntity<T>> for AnyWeakEntity
Source§fn from(entity: WeakEntity<T>) -> Self
fn from(entity: WeakEntity<T>) -> Self
Source§impl<V: 'static + Render> From<WeakEntity<V>> for AnyWeakView
impl<V: 'static + Render> From<WeakEntity<V>> for AnyWeakView
Source§fn from(view: WeakEntity<V>) -> Self
fn from(view: WeakEntity<V>) -> Self
Source§impl<T> Hash for WeakEntity<T>
impl<T> Hash for WeakEntity<T>
Source§impl<T: 'static> Ord for WeakEntity<T>
impl<T: 'static> Ord for WeakEntity<T>
Source§impl<T> PartialEq<Entity<T>> for WeakEntity<T>
impl<T> PartialEq<Entity<T>> for WeakEntity<T>
Source§impl<T> PartialEq<WeakEntity<T>> for Entity<T>
impl<T> PartialEq<WeakEntity<T>> for Entity<T>
Source§impl<T> PartialEq for WeakEntity<T>
impl<T> PartialEq for WeakEntity<T>
Source§impl<T: 'static> PartialOrd for WeakEntity<T>
impl<T: 'static> PartialOrd for WeakEntity<T>
impl<T> Eq for WeakEntity<T>
Auto Trait Implementations§
impl<T> Freeze for WeakEntity<T>
impl<T> !RefUnwindSafe for WeakEntity<T>
impl<T> Send for WeakEntity<T>
impl<T> Sync for WeakEntity<T>
impl<T> Unpin for WeakEntity<T>
impl<T> !UnwindSafe for WeakEntity<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more