Trait PluginAPI

Source
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§

Source

fn new() -> Result<Self, E>

Returns a new instance of the plugin. No initialization of the hardware is performed.

Source

fn init(&mut self) -> Result<(), E>

Initialzes the plugin by performing any hardware initialization.

Source

fn attributes(&self) -> &Attributes<Self, E>

Returns the attributes of the plugin.

Provided Methods§

Source

fn attribute_count(&self) -> usize

Returns the number of attributes of the plugin.

Source

fn attribute_ids(&self) -> Vec<usize>

Returns the attribute IDs.

Source

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
Source

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
Source

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 attribute
  • phase - the lifecycle phase of the plugin that determines which callbacks to use
Source

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 attribute
  • val - a reference to a Val instance
  • phase - 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.

Implementors§