pub struct PluginDriver<P>where
P: PluginExport,{ /* private fields */ }Implementations§
Source§impl<P> PluginDriver<P>where
P: PluginExport,
impl<P> PluginDriver<P>where
P: PluginExport,
pub fn new() -> PluginDriver<P>
pub fn sample_rate(self, sr: f64) -> PluginDriver<P>
pub fn channels(self, n: usize) -> PluginDriver<P>
pub fn block_size(self, n: usize) -> PluginDriver<P>
pub fn duration(self, d: Duration) -> PluginDriver<P>
pub fn transport(self, t: TransportSpec) -> PluginDriver<P>
pub fn bpm(self, bpm: f64) -> PluginDriver<P>
pub fn playing(self, playing: bool) -> PluginDriver<P>
pub fn input(self, source: InputSource) -> PluginDriver<P>
Sourcepub fn script(self, f: impl FnOnce(&mut Script)) -> PluginDriver<P>
pub fn script(self, f: impl FnOnce(&mut Script)) -> PluginDriver<P>
Build a script via a closure. Each set_param / note_on
/ etc. lands at the cursor’s current sample offset; wait_ms
advances the cursor.
Sourcepub fn set_param(self, id: impl Into<u32>, normalized: f64) -> PluginDriver<P>
pub fn set_param(self, id: impl Into<u32>, normalized: f64) -> PluginDriver<P>
Set a parameter to a normalized [0, 1] value before the run
starts. Equivalent to a setup(|p| p.params().set_normalized(id, v))
closure but written as one builder call. Multiple .set_param
calls compose; they run in declaration order, before the
.setup closure (if any).
For automation during a run, use .script(|s| s.set_param(...)),
which emits a sample-accurate ParamChange event the plugin
processes inline.
Sourcepub fn manifest_dir(self, dir: impl Into<PathBuf>) -> PluginDriver<P>
pub fn manifest_dir(self, dir: impl Into<PathBuf>) -> PluginDriver<P>
Anchor for state_file relative paths. Defaults to the
process CWD; callers from truce-test override it with the
test crate’s CARGO_MANIFEST_DIR via the screenshot!-style
macro pattern (see truce-test’s wrapping macro).
Sourcepub fn setup<F>(self, f: F) -> PluginDriver<P>
pub fn setup<F>(self, f: F) -> PluginDriver<P>
Mutate the plugin between init/reset+state-load and the
first process block. Use when the test needs more than
param tweaks - load arbitrary fields, drive a warmup
process() call to populate meters / lookahead, etc.
Composes with state_file (state loads first) and
set_param (shortcuts apply first); the closure runs last.
The closure receives a SetupContext with the resolved
channel count, sample rate, and block size - exactly what the
upcoming process loop will use. Channel resolution happens
before setup runs, so a closure that allocates per-channel
scratch can size correctly without re-querying P::bus_layouts.
Sourcepub fn state_blob(self, bytes: Vec<u8>) -> PluginDriver<P>
pub fn state_blob(self, bytes: Vec<u8>) -> PluginDriver<P>
Apply an in-memory .pluginstate blob via
plugin.load_state(&bytes) at the same lifecycle point as
Self::state_file (after init/reset, before set_param
shortcuts and setup). Use when the test already has the
bytes in hand and doesn’t want a temp file round-trip.
Sourcepub fn state_file(self, path: impl Into<PathBuf>) -> PluginDriver<P>
pub fn state_file(self, path: impl Into<PathBuf>) -> PluginDriver<P>
Read a .pluginstate file (the standalone host’s Cmd+S
save format) and apply it via plugin.load_state(&bytes)
after init/reset and before any set_param overrides /
setup closure. Path is resolved relative to
manifest_dir, or used as-is if absolute.
I/O is deferred to .run(). The builder records the path; a
missing or unreadable file panics at run time with the resolved
path in the message, alongside other run-time failures, rather
than from inside this method.
pub fn capture_audio(self, on: bool) -> PluginDriver<P>
pub fn capture_meters(self, m: MeterCapture) -> PluginDriver<P>
pub fn capture_output_events(self, on: bool) -> PluginDriver<P>
pub fn capture_block_snapshots(self, on: bool) -> PluginDriver<P>
Sourcepub fn run(self) -> DriverResult<P>
pub fn run(self) -> DriverResult<P>
Drive the plugin and return the captured result.
§Panics
Panics if a state_file(...) path cannot be read. Plugin
init / reset / process / restore_values panics propagate
unchanged so the underlying failure surfaces with its original
stack rather than being wrapped.