Struct FeatureCache

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

Source

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.

Source

pub fn contains<T: Feature>(&self) -> bool

Evaluate whether this object contains the requested feature.

Source

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>

Source§

fn clone(&self) -> FeatureCache<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> FeatureCollection<'a> for FeatureCache<'a>

Source§

fn from_cache( cache: &mut FeatureCache<'a>, _: ThreadingClass, ) -> Result<Self, MissingFeatureError>

Populate a collection with features from the cache for the given threading class.
Source§

impl<'a> IntoIterator for FeatureCache<'a>

Source§

type Item = FeatureDescriptor<'a>

The type of the elements being iterated over.
Source§

type IntoIter = Map<IntoIter<&'a CStr, *const c_void>, fn((&'a CStr, *const c_void)) -> FeatureDescriptor<'a>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for FeatureCache<'a>

§

impl<'a> RefUnwindSafe for FeatureCache<'a>

§

impl<'a> !Send for FeatureCache<'a>

§

impl<'a> !Sync for FeatureCache<'a>

§

impl<'a> Unpin for FeatureCache<'a>

§

impl<'a> UnwindSafe for FeatureCache<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.