pub trait ComponentProvider {
    // Required methods
    fn query_component_ref(&self, type_id: TypeId) -> Option<&dyn Any>;
    fn query_component_mut(&mut self, type_id: TypeId) -> Option<&mut dyn Any>;
}
Expand description

Component provider provides dynamic access to inner components of an object by their type id.

Required Methods§

source

fn query_component_ref(&self, type_id: TypeId) -> Option<&dyn Any>

Allows an object to provide access to inner components.

source

fn query_component_mut(&mut self, type_id: TypeId) -> Option<&mut dyn Any>

Allows an object to provide access to inner components.

Implementations§

source§

impl dyn ComponentProvider

source

pub fn component_ref<T: Any>(&self) -> Option<&T>

Tries to borrow a component of given type.

source

pub fn component_mut<T: Any>(&mut self) -> Option<&mut T>

Tries to borrow a component of given type.

Implementors§