ComponentInstanceProvider

Trait ComponentInstanceProvider 

Source
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§

Source

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.

Source

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.

Source

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.

Implementors§