[−][src]Trait kpal_plugin::PluginAPI
The set of functions that must be implemented by a plugin.
Required methods
fn new() -> Result<Self, E>
Returns a new instance of the plugin. No initialization of the hardware is performed.
fn init(&mut self) -> Result<(), E>
Initialzes the plugin by performing any hardware initialization.
fn attributes(&self) -> &Attributes<Self, E>
Returns the attributes of the plugin.
Provided methods
fn attribute_count(&self) -> usize
Returns the number of attributes of the plugin.
fn attribute_ids(&self) -> Vec<usize>
Returns the attribute IDs.
fn attribute_name(&self, id: usize) -> Result<Ref<CString>, E>
Returns the name of an attribute.
If the attribute that corresponds to the id
does not exist, then an error is
returned. Otherwise, the name is returned as a C-compatible &CStr
.
Arguments
id
- the numeric ID of the attribute
fn attribute_pre_init(&self, id: usize) -> Result<bool, E>
Indicates whether an attribute may be set before initialization.
Arguments
id
- the numeric ID of the attribute
fn attribute_value(&self, id: usize, phase: Phase) -> Result<Val, E>
Returns the value of an attribute.
If the attribute that corresponds to the id
does not exist, then an error is
returned. Otherwise, the value is returnd as a C-compatible tagged enum.
Arguments
id
- the numeric ID of the attributephase
- the lifecycle phase of the plugin that determines which callbacks to use
fn attribute_set_value(
&self,
id: usize,
val: &Val,
phase: Phase
) -> Result<(), E>
&self,
id: usize,
val: &Val,
phase: Phase
) -> Result<(), E>
Sets the value of the attribute given by the id.
If the attribute that corresponds to the id
does not exist, or if the attribute cannot be
set, then an error is returned.
Arguments
id
- the numeric ID of the attributeval
- a reference to a Val instancephase
- the lifecycle phase of the plugin that determines which callbacks to use