Skip to main content

IOptionalFeatureProvider

Trait IOptionalFeatureProvider 

Source
pub trait IOptionalFeatureProvider {
    // Required method
    fn try_get_feature(&self, feature_type: TypeId) -> Option<Rc<dyn Any>>;
}
Expand description

Something that can expose optional, backend-specific features by type.

Features are looked up by the TypeId of the feature’s type, which may be a trait object type (TypeId::of::<dyn IFoo>()); the returned value then holds an Rc<dyn IFoo>, or an Arc<dyn IFoo> for a feature that is shared by threads.

Required Methods§

Source

fn try_get_feature(&self, feature_type: TypeId) -> Option<Rc<dyn Any>>

Queries for an optional feature.

Implementations§

Source§

impl dyn IOptionalFeatureProvider + '_

Source

pub fn try_get<T: ?Sized + 'static>(&self) -> Option<Rc<T>>

Queries for an optional feature registered as Rc<T>.

Source

pub fn try_get_shared<T: ?Sized + 'static>(&self) -> Option<Arc<T>>

Queries for an optional feature registered as Arc<T>: one that is shared by threads.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§