Trait FeatureCollection

Source
pub trait FeatureCollection<'a>: Sized + 'a {
    // Required method
    fn from_cache(
        cache: &mut FeatureCache<'a>,
        class: ThreadingClass,
    ) -> Result<Self, MissingFeatureError>;
}
Expand description

Convenience trait for feature collections.

The feature cache is only for temporary use; Once a feature is retrieved, it is removed from the cache. Therefore you need a way to properly store features.

You can simply create a struct with features as it’s fields and derive FeatureCollection for it. A procedural macro will then create a method that populates the struct from the cache, or returns None if one of the required features is not in the cache.

An example using the few built-in features:

use lv2_core::plugin::*;
use lv2_core::feature::*;

#[derive(FeatureCollection)]
struct MyCollection {
    live: IsLive,
    hardrt: Option<HardRTCapable>,
}

Required Methods§

Source

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

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a> FeatureCollection<'a> for ()

Implementors§