pub trait ComponentProvider {
// Required methods
fn query_component_ref(
&self,
type_id: TypeId,
) -> Option<&(dyn Any + 'static)>;
fn query_component_mut(
&mut self,
type_id: TypeId,
) -> Option<&mut (dyn Any + 'static)>;
}
Expand description
Component provider provides dynamic access to inner components of an object by their type id.
Required Methods§
Sourcefn query_component_ref(&self, type_id: TypeId) -> Option<&(dyn Any + 'static)>
fn query_component_ref(&self, type_id: TypeId) -> Option<&(dyn Any + 'static)>
Allows an object to provide access to inner components.
Sourcefn query_component_mut(
&mut self,
type_id: TypeId,
) -> Option<&mut (dyn Any + 'static)>
fn query_component_mut( &mut self, type_id: TypeId, ) -> Option<&mut (dyn Any + 'static)>
Allows an object to provide access to inner components.
Implementations§
Source§impl dyn ComponentProvider
impl dyn ComponentProvider
Sourcepub fn component_ref<T>(&self) -> Option<&T>where
T: Any,
pub fn component_ref<T>(&self) -> Option<&T>where
T: Any,
Tries to borrow a component of given type.
Sourcepub fn component_mut<T>(&mut self) -> Option<&mut T>where
T: Any,
pub fn component_mut<T>(&mut self) -> Option<&mut T>where
T: Any,
Tries to borrow a component of given type.