pub struct WeakEntity<T> { /* private fields */ }Expand description
A weak reference to a entity of the given type.
Implementations§
Source§impl<T> WeakEntity<T>where
T: 'static,
impl<T> WeakEntity<T>where
T: 'static,
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, Error>where
C: AppContext,
pub fn update<C, R>(
&self,
cx: &mut C,
update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R,
) -> Result<R, Error>where
C: AppContext,
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, Error>where
C: AppContext,
pub fn update_in<C, R>(
&self,
cx: &mut C,
update: impl FnOnce(&mut T, &mut Window, &mut Context<'_, T>) -> R,
) -> Result<R, Error>where
C: AppContext,
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, Error>where
C: AppContext,
pub fn read_with<C, R>(
&self,
cx: &C,
read: impl FnOnce(&T, &App) -> R,
) -> Result<R, Error>where
C: AppContext,
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() -> WeakEntity<T>
pub fn new_invalid() -> WeakEntity<T>
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§fn clone(&self) -> WeakEntity<T>
fn clone(&self) -> WeakEntity<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§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§type Target = AnyWeakEntity
type Target = AnyWeakEntity
Source§impl<T> DerefMut for WeakEntity<T>
impl<T> DerefMut for WeakEntity<T>
impl<T> Eq for WeakEntity<T>
Source§impl<T> From<WeakEntity<T>> for AnyWeakEntity
impl<T> From<WeakEntity<T>> for AnyWeakEntity
Source§fn from(entity: WeakEntity<T>) -> AnyWeakEntity
fn from(entity: WeakEntity<T>) -> AnyWeakEntity
Source§impl<V> From<WeakEntity<V>> for AnyWeakViewwhere
V: 'static + Render,
impl<V> From<WeakEntity<V>> for AnyWeakViewwhere
V: 'static + Render,
Source§fn from(view: WeakEntity<V>) -> AnyWeakView
fn from(view: WeakEntity<V>) -> AnyWeakView
Source§impl<T> Hash for WeakEntity<T>
impl<T> Hash for WeakEntity<T>
Source§impl<T> Ord for WeakEntity<T>where
T: 'static,
impl<T> Ord for WeakEntity<T>where
T: 'static,
Source§fn cmp(&self, other: &WeakEntity<T>) -> Ordering
fn cmp(&self, other: &WeakEntity<T>) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T> PartialEq for WeakEntity<T>
impl<T> PartialEq 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> PartialOrd for WeakEntity<T>where
T: 'static,
impl<T> PartialOrd for WeakEntity<T>where
T: 'static,
Auto Trait Implementations§
impl<T> !RefUnwindSafe for WeakEntity<T>
impl<T> !UnwindSafe for WeakEntity<T>
impl<T> Freeze for WeakEntity<T>
impl<T> Send for WeakEntity<T>
impl<T> Sync for WeakEntity<T>
impl<T> Unpin for WeakEntity<T>
impl<T> UnsafeUnpin 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