Module rsynth::meta [−][src]
Mechanisms for defining the meta-data of a plugin or application.
rsynth
uses a hierarchy of different traits that allow your audio application
or plug-in to define various aspects of the meta-data.
Implementing each of these traits one by one can be rather tedious.
For this reason, these traits have blanket impls, so that you only need
to implement the Meta
trait and in its implementation, return the
meta-data.
Example
use rsynth::meta::{Meta, MetaData, InOut}; struct MyPlugin { meta: MetaData<&'static str, &'static str, &'static str> /* ... */ } impl MyPlugin { pub fn new() -> Self { Self { meta: MetaData { general_meta: unimplemented!(), audio_port_meta: InOut { inputs: vec![unimplemented!()], outputs: vec![unimplemented!()], }, midi_port_meta: InOut { inputs: vec![unimplemented!()], outputs: vec![unimplemented!()], }, } } } } impl Meta for MyPlugin { type MetaData = MetaData<&'static str, &'static str, &'static str>; fn meta(&self) -> &Self::MetaData { &self.meta } }
How it works under the hood
Back-ends may require the plugin to implement a number of traits concerning meta-data.
Suppose for instance a backend requires plugins to implement the CommonPluginMeta
trait.
The CommonPluginMeta
trait defines the “name” of the plugin.
There is a blanket impl that implements the CommonPluginMeta
for any type that
implements Meta
where the associated type Meta::MetaData
implements the General
trait
(which allows getting general meta-data) where the associated type General::GeneralData
implements the Name
trait.
Now the MetaData<G, _, _>
struct implements General
with associated type
General::GeneralData
equal to G
.
Also, Name
is implemented for String
and for &'static str
.
So if a plugin implements Meta
with the associated type Meta::MetaData
equal to the struct
MetaData<&'static str, _, _>
, then it automatically implements CommonPluginMeta
.
Structs
AudioPort | A “marker” struct to be used as a type parameter for the |
InOut | Represents meta-data about a input and output ports. |
MetaData | Represents general-purpose meta-data of an audio application or plugin. |
MidiPort | A “marker” struct to be used as a type parameter for the |
Traits
General | Define meta-data of an application or plugin as a whole. |
Meta | Define the meta-data for an application or plug-in. |
Name | Implement this trait to indicate that a type can be used to represent meta-data that contains a name. |
Port | Define meta-data for input ports and output ports. |