pub struct FeatureCache<'a> { /* private fields */ }
Expand description
Cache for host features, used in the feature discovery stage.
At initialization time, a raw LV2 plugin receives a null-terminated array containing all requested host features. Obviously, this is not suited for safe Rust code and therefore, it needs an abstraction layer.
Internally, this struct contains a hash map which is filled the raw LV2 feature descriptors. Using this map, methods are defined to identify and retrieve features.
Implementations§
Source§impl<'a> FeatureCache<'a>
impl<'a> FeatureCache<'a>
Sourcepub unsafe fn from_raw(raw: *const *const LV2_Feature) -> Self
pub unsafe fn from_raw(raw: *const *const LV2_Feature) -> Self
Construct a cache from the raw features array.
It basically populates a hash map by walking through the array and then creates a FeatureContainer
with it. However, this method is unsafe since it dereferences a C string to a URI. Also, this method should only be used with the features list supplied by the host since the soundness of the whole module depends on that assumption.
§Safety
This method is unsafe since it needs to dereference the raw feature pointers.
Sourcepub fn contains<T: Feature>(&self) -> bool
pub fn contains<T: Feature>(&self) -> bool
Evaluate whether this object contains the requested feature.
Sourcepub fn retrieve_feature<F: Feature, T: FromResolvedFeature<F>>(
&mut self,
class: ThreadingClass,
) -> Result<T, MissingFeatureError>
pub fn retrieve_feature<F: Feature, T: FromResolvedFeature<F>>( &mut self, class: ThreadingClass, ) -> Result<T, MissingFeatureError>
Try to retrieve a feature.
If the feature is not found, this method will return None
. Since the resulting feature object may have mutable access to the raw data, it will be removed from the cache to avoid aliasing.
You also have to provide the threading class of the feature you want to retrieve.
Trait Implementations§
Source§impl<'a> Clone for FeatureCache<'a>
impl<'a> Clone for FeatureCache<'a>
Source§fn clone(&self) -> FeatureCache<'a>
fn clone(&self) -> FeatureCache<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more