pub trait ComponentInstanceProvider {
// Required methods
fn primary_instance(
&mut self,
type_id: TypeId,
) -> Result<(ComponentInstanceAnyPtr, CastFunction), ComponentInstanceProviderError>;
fn instances(
&mut self,
type_id: TypeId,
) -> Result<Vec<(ComponentInstanceAnyPtr, CastFunction)>, ComponentInstanceProviderError>;
fn instance_by_name(
&mut self,
name: &str,
type_id: TypeId,
) -> Result<(ComponentInstanceAnyPtr, CastFunction), ComponentInstanceProviderError>;
}Required Methods§
Sourcefn primary_instance(
&mut self,
type_id: TypeId,
) -> Result<(ComponentInstanceAnyPtr, CastFunction), ComponentInstanceProviderError>
fn primary_instance( &mut self, type_id: TypeId, ) -> Result<(ComponentInstanceAnyPtr, CastFunction), ComponentInstanceProviderError>
Tries to return a primary instance of a given component. A primary component is either the only one registered or one marked as primary.
Sourcefn instances(
&mut self,
type_id: TypeId,
) -> Result<Vec<(ComponentInstanceAnyPtr, CastFunction)>, ComponentInstanceProviderError>
fn instances( &mut self, type_id: TypeId, ) -> Result<Vec<(ComponentInstanceAnyPtr, CastFunction)>, ComponentInstanceProviderError>
Tries to instantiate and return all registered components for given type, stopping on first error. Be aware this might be an expensive operation if the number of registered components is high.
Sourcefn instance_by_name(
&mut self,
name: &str,
type_id: TypeId,
) -> Result<(ComponentInstanceAnyPtr, CastFunction), ComponentInstanceProviderError>
fn instance_by_name( &mut self, name: &str, type_id: TypeId, ) -> Result<(ComponentInstanceAnyPtr, CastFunction), ComponentInstanceProviderError>
Tries to return an instance with the given name and type.