pub enum ResourceHostRef {
Element(Ref<StyledElement>),
Other(Rc<dyn IResourceHost>),
}Expand description
A strong reference to a resource host: a styled element, or another host such as the application object.
Variants§
Element(Ref<StyledElement>)
Other(Rc<dyn IResourceHost>)
Implementations§
Source§impl ResourceHostRef
impl ResourceHostRef
Sourcepub fn downgrade(&self) -> WeakResourceHost
pub fn downgrade(&self) -> WeakResourceHost
Creates a weak reference to the host.
Sourcepub fn as_element(&self) -> Option<&Ref<StyledElement>>
pub fn as_element(&self) -> Option<&Ref<StyledElement>>
The host as a styled element, if it is one.
Source§impl ResourceHostRef
impl ResourceHostRef
Sourcepub fn resource_observable(
&self,
key: impl Into<ResourceKey>,
converter: Option<ResourceConverter>,
) -> Rc<dyn IObservable<Option<BoxedValue>>>
pub fn resource_observable( &self, key: impl Into<ResourceKey>, converter: Option<ResourceConverter>, ) -> Rc<dyn IObservable<Option<BoxedValue>>>
Gets an observable for the resource with the specified key.
The observable produces the current value on subscription and a new value whenever the resources visible to the host, or its theme variant, change. It holds the host weakly; while it has observers the host keeps it alive.
Methods from Deref<Target = dyn IResourceHost>§
Sourcepub fn find_resource(&self, key: &ResourceKey) -> ResourceValue
pub fn find_resource(&self, key: &ResourceKey) -> ResourceValue
Finds the specified resource by searching up the logical tree and then global styles.
Returns the resource, or the unset value marker if not found.
Sourcepub fn find_resource_for_theme(
&self,
theme: Option<&ThemeVariant>,
key: &ResourceKey,
) -> ResourceValue
pub fn find_resource_for_theme( &self, theme: Option<&ThemeVariant>, key: &ResourceKey, ) -> ResourceValue
Finds the specified resource for a theme variant by searching up the logical tree and then global styles.
Returns the resource, or the unset value marker if not found.
Sourcepub fn try_find_resource(
&self,
key: &ResourceKey,
theme: Option<&ThemeVariant>,
) -> Option<ResourceValue>
pub fn try_find_resource( &self, key: &ResourceKey, theme: Option<&ThemeVariant>, ) -> Option<ResourceValue>
Tries to find the specified resource by searching up the logical tree and then global styles.
Trait Implementations§
Source§impl Clone for ResourceHostRef
impl Clone for ResourceHostRef
Source§impl Deref for ResourceHostRef
impl Deref for ResourceHostRef
Source§type Target = dyn IResourceHost
type Target = dyn IResourceHost
Source§fn deref(&self) -> &(dyn IResourceHost + 'static)
fn deref(&self) -> &(dyn IResourceHost + 'static)
Source§impl<T: ObjectType + Upcast<StyledElement>> From<&Ref<T>> for ResourceHostRef
impl<T: ObjectType + Upcast<StyledElement>> From<&Ref<T>> for ResourceHostRef
Source§impl<T: IResourceHost + 'static> From<Rc<T>> for ResourceHostRef
impl<T: IResourceHost + 'static> From<Rc<T>> for ResourceHostRef
Source§impl From<Rc<dyn IResourceHost>> for ResourceHostRef
impl From<Rc<dyn IResourceHost>> for ResourceHostRef
Source§fn from(value: Rc<dyn IResourceHost>) -> Self
fn from(value: Rc<dyn IResourceHost>) -> Self
Source§impl<T: ObjectType + Upcast<StyledElement>> From<Ref<T>> for ResourceHostRef
impl<T: ObjectType + Upcast<StyledElement>> From<Ref<T>> for ResourceHostRef
Auto Trait Implementations§
impl !RefUnwindSafe for ResourceHostRef
impl !Send for ResourceHostRef
impl !Sync for ResourceHostRef
impl !UnwindSafe for ResourceHostRef
impl Freeze for ResourceHostRef
impl Unpin for ResourceHostRef
impl UnsafeUnpin for ResourceHostRef
Blanket Implementations§
Source§impl<T> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
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> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more