Skip to main content

Crate truce_loader

Crate truce_loader 

Source
Expand description

Hot-reload mechanics for truce: dylib loading, ABI canary, vtable probe, and the shells (HotShell<P, S>, StaticShell<P, L, S>) that bridge the user-facing truce_plugin::PluginLogic / truce_plugin::PluginLogic64 leaf traits onto truce_core::Plugin for format wrappers.

Plugin authors don’t reach into this crate directly. They write impl PluginLogic for MyPlugin (the leaf trait is sample-pinned via the prelude re-export) and the truce::plugin! macro picks the static or hot shell based on the shell Cargo feature.

§ABI boundary

Across the dylib boundary the shell holds a Box<dyn truce_plugin::PluginLogicCore<S>> - the generic wrapper-facing trait that both leaf traits forward into via blanket impls in truce-plugin. The single trait object carries DSP and GUI methods through one vtable, with S baked in by the shell’s generic parameter (and recorded in AbiCanary::sample_precision so a precision mismatch fails the canary check before vtable-binding).

use truce_loader::{AbiCanary, PluginLogic, PluginLogicCore};

struct MyPlugin { /* ... */ }
impl PluginLogic for MyPlugin { /* DSP + GUI */ }

// Emitted by `truce::plugin!`; plugin authors don't write these
// by hand. `Sample` resolves through the prelude alias
// (`f32` for `prelude` / `prelude32` / `prelude64m`,
// `f64` for `prelude64`). The macro also emits a
// `truce_vtable_probe` symbol that constructs an internal
// `ProbePlugin`; that type lives in `__macro_deps` and isn't
// intended for direct use.
#[unsafe(no_mangle)]
pub fn truce_create(p: *const ()) -> Box<dyn PluginLogicCore<Sample>> {
    Box::new(MyPlugin::new(/* params from p */))
}

#[unsafe(no_mangle)]
pub fn truce_abi_canary() -> AbiCanary { AbiCanary::current::<Sample>() }

Modules§

static_shell
StaticShell - embeds the plugin directly into the binary.

Macros§

export_plugin
Export the #[unsafe(no_mangle)] functions required by the shell.
export_static
Compile-time static embedding of a PluginLogic impl into the binary.

Structs§

AbiCanary
ABI fingerprint. Compared between shell and dylib before loading.
AudioBuffer
Non-interleaved audio buffer. Borrows host memory through the format wrapper.
Color
Color as RGBA (0.0–1.0).
Event
A timestamped event within a process block.
EventList
Ordered list of events within a process block.
ProcessContext
Per-block context handed to process(). Construct via Self::new + the with_* builders. Marked #[non_exhaustive] so adding host-populated fields in future (e.g. host_latency, bus_routing) isn’t a SemVer break for downstream pre-1.0 callers.
Theme
Visual theme for the built-in GUI.
TransportInfo
Host-populated transport snapshot. Constructed by every format wrapper from the host’s own transport struct via struct-literal expressions, so this stays “exhaustive” (no #[non_exhaustive], which would block cross-crate construction). Adding a new field is a coordinated workspace-wide change.
WidgetRegion
A widget’s hit region on screen.

Enums§

EventBody
ProcessStatus

Traits§

PluginLogic
The f32-buffer user-facing plugin trait.
PluginLogic64
The f64-buffer user-facing plugin trait. Same surface as PluginLogic but with the audio buffer pinned to f64.
PluginLogicCore
Wrapper-facing plugin trait, generic over the audio sample type.
RenderBackend
Abstraction over rendering backends (CPU via tiny-skia, GPU via wgpu).