[][src]Trait lv2_core::feature::Feature

pub unsafe trait Feature: UriBound + Sized {
    unsafe fn from_feature_ptr(
        feature: *const c_void,
        class: ThreadingClass
    ) -> Option<Self>; }

Trait to generalize the feature detection system.

A host that only implements the core LV2 specification does not have much functionality. Instead, hosts can provide extra functionalities, called "host features" or short "features", which a make plugins more useful.

A native plugin written in C would discover a host's features by iterating through an array of URIs and pointers. When it finds the URI of the feature it is looking for, it casts the pointer to the type of the feature interface and uses the information from the interface.

In Rust, most of this behaviour is done internally and instead of simply casting a pointer, a safe feature descriptor, which implements this trait, is constructed using the from_raw_data method.

Some host features may only be used in certain threading classes. This is guarded by Rust-LV2 by passing the threading class in which the plugin will be used to the feature, which then may take different actions.

Required methods

unsafe fn from_feature_ptr(
    feature: *const c_void,
    class: ThreadingClass
) -> Option<Self>

Create an instance of the featurer.

The feature pointer is provided by the host and points to the feature-specific data. If the data is invalid, for one reason or another, the method returns None.

Implementing

If nescessary, you should dereference it and store the reference inside the feature struct in order to use it.

You have to document in which threading classes your feature can be used and should panic if the threading class is not supported. When this happens when the plugin programmer has added your feature to the wrong feature collection, which is considered a programming error and therefore justifies the panic. If you don't panic in this case, the error is handled silently, which may make debugging harder.

You should always allow the Other threading class in order to restrict your feature from use cases you might not know.

Safety

This method is unsafe since it has to de-reference a pointer.

Loading content...

Implementors

impl Feature for HardRTCapable[src]

impl Feature for InPlaceBroken[src]

impl Feature for IsLive[src]

Loading content...