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::PluginRuntime 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
PluginLogicimpl into the binary.
Structs§
- AbiCanary
- ABI fingerprint. Compared between shell and dylib before loading.
- Audio
Buffer - 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.
- Event
List - Ordered list of events within a process block.
- Process
Context - Per-block context handed to
process(). Construct viaSelf::new+ thewith_*builders. Marked#[non_exhaustive]so adding host-populated fields in future (e.g.host_latency,bus_routing) isn’t aSemVerbreak for downstream pre-1.0 callers. - Theme
- Visual theme for the built-in GUI.
- Transport
Info - 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. - Widget
Region - A widget’s hit region on screen.
Enums§
Traits§
- Plugin
Logic - The
f32-buffer user-facing plugin trait. - Plugin
Logic64 - The
f64-buffer user-facing plugin trait. Same surface asPluginLogicbut with the audio buffer pinned tof64. - Plugin
Logic Core - Wrapper-facing plugin trait, generic over the audio sample type.