pub struct Entity<T> { /* private fields */ }Expand description
A strong, well-typed reference to a struct which is managed by GPUI
Implementations§
Source§impl<T> Entity<T>where
T: 'static,
impl<T> Entity<T>where
T: 'static,
Sourcepub fn downgrade(&self) -> WeakEntity<T>
pub fn downgrade(&self) -> WeakEntity<T>
Downgrade this entity pointer to a non-retaining weak pointer
Sourcepub fn read_with<R, C>(&self, cx: &C, f: impl FnOnce(&T, &App) -> R) -> Rwhere
C: AppContext,
pub fn read_with<R, C>(&self, cx: &C, f: impl FnOnce(&T, &App) -> R) -> Rwhere
C: AppContext,
Read the entity referenced by this handle with the given function.
Sourcepub fn update<R, C>(
&self,
cx: &mut C,
update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R,
) -> Rwhere
C: AppContext,
pub fn update<R, C>(
&self,
cx: &mut C,
update: impl FnOnce(&mut T, &mut Context<'_, T>) -> R,
) -> Rwhere
C: AppContext,
Updates the entity referenced by this handle with the given function.
Sourcepub fn as_mut<'a, C>(&self, cx: &'a mut C) -> GpuiBorrow<'a, T>where
C: AppContext,
pub fn as_mut<'a, C>(&self, cx: &'a mut C) -> GpuiBorrow<'a, T>where
C: AppContext,
Updates the entity referenced by this handle with the given function.
Sourcepub fn write<C>(&self, cx: &mut C, value: T)where
C: AppContext,
pub fn write<C>(&self, cx: &mut C, value: T)where
C: AppContext,
Updates the entity referenced by this handle with the given function.
Sourcepub fn update_in<R, C>(
&self,
cx: &mut C,
update: impl FnOnce(&mut T, &mut Window, &mut Context<'_, T>) -> R,
) -> <C as VisualContext>::Result<R>where
C: VisualContext,
pub fn update_in<R, C>(
&self,
cx: &mut C,
update: impl FnOnce(&mut T, &mut Window, &mut Context<'_, T>) -> R,
) -> <C as VisualContext>::Result<R>where
C: VisualContext,
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 window has been closed.
Source§impl<T> Entity<T>where
T: Render,
impl<T> Entity<T>where
T: Render,
Sourcepub fn cached(self, style: StyleRefinement) -> ViewElement<Entity<T>>
pub fn cached(self, style: StyleRefinement) -> ViewElement<Entity<T>>
Embed this entity as a cached [ViewElement] laid out at style.
The rendered subtree is reused until the entity is notified (or the
cached bounds / text style change). Caching requires a definite size:
a cached view is laid out from style and is not measured from its
contents. Use [ViewElement::new] (or .child(entity)) for the
uncached case.
Methods from Deref<Target = AnyEntity>§
Sourcepub fn entity_type(&self) -> TypeId
pub fn entity_type(&self) -> TypeId
Returns the TypeId associated with this entity.
Sourcepub fn downgrade(&self) -> AnyWeakEntity
pub fn downgrade(&self) -> AnyWeakEntity
Converts this entity handle into a weak variant, which does not prevent it from being released.
Trait Implementations§
impl<T> Eq for Entity<T>
Source§impl<V> Focusable for Entity<V>where
V: Focusable,
impl<V> Focusable for Entity<V>where
V: Focusable,
Source§fn focus_handle(&self, cx: &App) -> FocusHandle
fn focus_handle(&self, cx: &App) -> FocusHandle
Source§impl<I> From<Entity<I>> for AnyImageCachewhere
I: ImageCache,
impl<I> From<Entity<I>> for AnyImageCachewhere
I: ImageCache,
Source§fn from(image_cache: Entity<I>) -> AnyImageCache
fn from(image_cache: Entity<I>) -> AnyImageCache
Source§impl<T> ImageCacheProvider for Entity<T>where
T: ImageCache,
impl<T> ImageCacheProvider for Entity<T>where
T: ImageCache,
Source§impl<V> IntoElement for Entity<V>where
V: 'static + Render,
impl<V> IntoElement for Entity<V>where
V: 'static + Render,
Source§type Element = ViewElement<Entity<V>>
type Element = ViewElement<Entity<V>>
Source§fn into_element(self) -> <Entity<V> as IntoElement>::Element
fn into_element(self) -> <Entity<V> as IntoElement>::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl<T> Ord for Entity<T>where
T: 'static,
impl<T> Ord for Entity<T>where
T: 'static,
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> PanelView for Entity<T>where
T: Panel,
impl<T> PanelView for Entity<T>where
T: Panel,
fn panel_name(&self, cx: &App) -> &'static str
fn panel_id(&self, _: &App) -> PanelId
fn closable(&self, cx: &App) -> bool
fn zoomable(&self, cx: &App) -> bool
fn visible(&self, cx: &App) -> bool
fn set_active(&self, active: bool, window: &mut Window, cx: &mut App)
fn set_zoomed(&self, zoomed: bool, window: &mut Window, cx: &mut App)
fn on_added_to( &self, group: WeakEntity<TabGroup>, window: &mut Window, cx: &mut App, )
fn on_removed(&self, window: &mut Window, cx: &mut App)
fn view(&self) -> AnyView
fn focus_handle(&self, cx: &App) -> FocusHandle
fn dump(&self, cx: &App) -> PanelState
Source§impl<T> PanelView for Entity<T>where
T: Panel,
impl<T> PanelView for Entity<T>where
T: Panel,
fn tab_name(&self, cx: &App) -> Option<SharedString>
fn title(&self, window: &mut Window, cx: &mut App) -> AnyElement
fn title_style(&self, cx: &App) -> Option<TitleStyle>
fn title_suffix(&self, window: &mut Window, cx: &mut App) -> Option<AnyElement>
fn zoom_control(&self, cx: &App) -> Option<PanelControl>
fn inner_padding(&self, cx: &App) -> bool
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 Entity<T>where
T: 'static,
impl<T> PartialOrd for Entity<T>where
T: 'static,
Source§impl<T> UniformListDecoration for Entity<T>where
T: UniformListDecoration + 'static,
impl<T> UniformListDecoration for Entity<T>where
T: UniformListDecoration + 'static,
Source§fn compute(
&self,
visible_range: Range<usize>,
bounds: Bounds<Pixels>,
scroll_offset: Point<Pixels>,
item_height: Pixels,
item_count: usize,
window: &mut Window,
cx: &mut App,
) -> AnyElement
fn compute( &self, visible_range: Range<usize>, bounds: Bounds<Pixels>, scroll_offset: Point<Pixels>, item_height: Pixels, item_count: usize, window: &mut Window, cx: &mut App, ) -> AnyElement
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Entity<T>
impl<T> !UnwindSafe for Entity<T>
impl<T> Freeze for Entity<T>
impl<T> Send for Entity<T>
impl<T> Sync for Entity<T>
impl<T> Unpin for Entity<T>
impl<T> UnsafeUnpin for Entity<T>
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
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> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
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