pub trait PluginCore: Send {
Show 17 methods
// Required methods
fn info(&self) -> &PluginInfo;
fn active_layout(&self) -> Option<&BusLayout>;
fn supported_layouts(&self) -> &[BusLayout];
fn parameter_count(&self) -> usize;
fn parameter_info(&self, index: usize) -> Result<ParameterInfo>;
fn parameter_value(&self, index: usize) -> Result<f64>;
fn parameter_value_string(&self, index: usize, value: f64) -> Result<String>;
fn set_parameter(&mut self, index: usize, value: f64) -> Result<()>;
fn preset_count(&self) -> usize;
fn preset_info(&self, index: usize) -> Result<PresetInfo>;
fn load_preset(&mut self, preset_number: i32) -> Result<()>;
fn save_state(&self) -> Result<Vec<u8>>;
fn load_state(&mut self, bytes: &[u8]) -> Result<()>;
fn activate(
&mut self,
layout: BusLayout,
sample_rate: f64,
max_block_size: usize,
) -> Result<()>;
fn deactivate(&mut self);
fn is_active(&self) -> bool;
// Provided method
fn editor(&mut self) -> Option<&mut dyn PluginEditor> { ... }
}Expand description
Core sample-precision-erased interface every plugin exposes.
Methods that don’t touch audio samples are here so a host can
query metadata before deciding whether to instantiate as
Plugin<f32> or Plugin<f64>. Mirrors truce’s
PluginLogicCore shape — the leaf Plugin<S> adds the
sample-typed process.
Required Methods§
Sourcefn info(&self) -> &PluginInfo
fn info(&self) -> &PluginInfo
Plugin metadata as the wrapper scanned it.
Sourcefn active_layout(&self) -> Option<&BusLayout>
fn active_layout(&self) -> Option<&BusLayout>
The bus layout currently active. None until
PluginCore::activate picks one.
Sourcefn supported_layouts(&self) -> &[BusLayout]
fn supported_layouts(&self) -> &[BusLayout]
All bus layouts the plugin supports. The host picks one
and passes it to activate. Returned by reference into
internally-cached metadata; cheap to call repeatedly.
Sourcefn parameter_count(&self) -> usize
fn parameter_count(&self) -> usize
Number of parameters this plugin exposes.
Sourcefn parameter_info(&self, index: usize) -> Result<ParameterInfo>
fn parameter_info(&self, index: usize) -> Result<ParameterInfo>
Metadata for parameter at index (0-based into the
plugin’s declared list).
§Errors
Returns crate::Error::InvalidParameter when index >= parameter_count().
Sourcefn parameter_value(&self, index: usize) -> Result<f64>
fn parameter_value(&self, index: usize) -> Result<f64>
Current value of parameter index in its native unit.
§Errors
Returns crate::Error::InvalidParameter when out of
range or crate::Error::NotActivated when called before
activate.
Sourcefn parameter_value_string(&self, index: usize, value: f64) -> Result<String>
fn parameter_value_string(&self, index: usize, value: f64) -> Result<String>
Format the parameter value at index as the plugin
would render it in its own UI. Many formats supply this
directly (clap_param_info_value_to_text); others
require host-side formatting.
§Errors
Returns crate::Error::InvalidParameter when index is
out of range or crate::Error::NotActivated when called
before activate.
Sourcefn set_parameter(&mut self, index: usize, value: f64) -> Result<()>
fn set_parameter(&mut self, index: usize, value: f64) -> Result<()>
Set parameter index to value in native units. Set
outside process (this is the host-thread setter); the
plugin may smooth toward the new value over subsequent
blocks.
§Errors
Returns crate::Error::InvalidParameter when out of
range or crate::Error::NotActivated when called before
activate.
Sourcefn preset_count(&self) -> usize
fn preset_count(&self) -> usize
Number of factory presets, if the plugin exposes any.
Sourcefn preset_info(&self, index: usize) -> Result<PresetInfo>
fn preset_info(&self, index: usize) -> Result<PresetInfo>
Sourcefn load_preset(&mut self, preset_number: i32) -> Result<()>
fn load_preset(&mut self, preset_number: i32) -> Result<()>
Load preset by the format-specific id from
PresetInfo::preset_number.
§Errors
Wrapper-specific — typically when the id is unknown.
Sourcefn save_state(&self) -> Result<Vec<u8>>
fn save_state(&self) -> Result<Vec<u8>>
Snapshot plugin state to a byte blob. Wrap in
crate::StateEnvelope before persisting if the host
wants the version / format header.
§Errors
Wrapper-specific.
Sourcefn load_state(&mut self, bytes: &[u8]) -> Result<()>
fn load_state(&mut self, bytes: &[u8]) -> Result<()>
Restore plugin state from bytes previously returned by
PluginCore::save_state. The host strips its own
envelope before calling this — the bytes here are
plugin-opaque.
§Errors
Wrapper-specific.
Sourcefn activate(
&mut self,
layout: BusLayout,
sample_rate: f64,
max_block_size: usize,
) -> Result<()>
fn activate( &mut self, layout: BusLayout, sample_rate: f64, max_block_size: usize, ) -> Result<()>
Pick a bus layout and prepare the plugin for processing
at sample_rate with blocks up to max_block_size
frames.
Hosts must call activate before any process call.
Subsequent reconfiguration (sample-rate change, layout
switch) requires a deactivate + activate cycle.
§Errors
Wrapper-specific — typically when the requested layout
isn’t in PluginCore::supported_layouts.
Sourcefn deactivate(&mut self)
fn deactivate(&mut self)
Tear down the active processing config. After this call
the plugin holds no per-activation resources and process
won’t be called until the next activate.
Sourcefn is_active(&self) -> bool
fn is_active(&self) -> bool
true when PluginCore::activate has been called and
PluginCore::deactivate hasn’t been called since.
Provided Methods§
Sourcefn editor(&mut self) -> Option<&mut dyn PluginEditor>
fn editor(&mut self) -> Option<&mut dyn PluginEditor>
Borrow the plugin’s editor controller if the plugin
exposes a custom GUI. Returns None for headless plugins
or plugins whose editor extension is missing.
The returned reference borrows &mut self, which means the
host can’t call process (which also needs &mut self)
while holding it. That’s the Rust-level enforcement of the
“audio thread vs UI thread” discipline.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".