pub trait PluginAPI<E: Error + PluginError + 'static>where
Self: Sized,{
// Required methods
fn new() -> Result<Self, E>;
fn init(&mut self) -> Result<(), E>;
fn attributes(&self) -> &Attributes<Self, E>;
// Provided methods
fn attribute_count(&self) -> usize { ... }
fn attribute_ids(&self) -> Vec<usize> { ... }
fn attribute_name(&self, id: usize) -> Result<Ref<'_, CString>, E> { ... }
fn attribute_pre_init(&self, id: usize) -> Result<bool, E> { ... }
fn attribute_value(&self, id: usize, phase: Phase) -> Result<Val, E> { ... }
fn attribute_set_value(
&self,
id: usize,
val: &Val,
phase: Phase,
) -> Result<(), E> { ... }
}
Expand description
The set of functions that must be implemented by a plugin.
Required Methods§
Sourcefn new() -> Result<Self, E>
fn new() -> Result<Self, E>
Returns a new instance of the plugin. No initialization of the hardware is performed.
Sourcefn init(&mut self) -> Result<(), E>
fn init(&mut self) -> Result<(), E>
Initialzes the plugin by performing any hardware initialization.
Sourcefn attributes(&self) -> &Attributes<Self, E>
fn attributes(&self) -> &Attributes<Self, E>
Returns the attributes of the plugin.
Provided Methods§
Sourcefn attribute_count(&self) -> usize
fn attribute_count(&self) -> usize
Returns the number of attributes of the plugin.
Sourcefn attribute_ids(&self) -> Vec<usize>
fn attribute_ids(&self) -> Vec<usize>
Returns the attribute IDs.
Sourcefn attribute_name(&self, id: usize) -> Result<Ref<'_, CString>, E>
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
Sourcefn attribute_pre_init(&self, id: usize) -> Result<bool, E>
fn attribute_pre_init(&self, id: usize) -> Result<bool, E>
Sourcefn attribute_value(&self, id: usize, phase: Phase) -> Result<Val, E>
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
Sourcefn attribute_set_value(
&self,
id: usize,
val: &Val,
phase: Phase,
) -> Result<(), E>
fn attribute_set_value( &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
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.