Skip to main content

Module state

Module state 

Source

Structs§

DeserializedState
Deserialized state.

Enums§

RestoreError
Errors restore_plugin can return.
StateLoadError
Reason a crate::PluginRuntime::load_state / truce_plugin::PluginLogic::load_state implementation failed to interpret the host-supplied extra-state blob. Format wrappers receive this on the audio-thread apply path and log it; hosts that surface a non-success code to the DAW (e.g. CLAP state_load returning false) read the variant via that path.

Functions§

apply_params
Apply just the parameter values from a deserialized state - the host-thread-safe subset of apply_state. Format wrappers call this from their state-load callback (host main thread) before pushing the full state onto the audio-thread handoff queue, so host-thread reads of getParameter/equivalents see the restored values immediately. Validators (auval, pluginval, the VST2 binary smoke) read parameters synchronously after setChunk/equivalents without first running a render block, and would otherwise see the pre-restore values until the audio thread caught up.
apply_state
Apply a deserialized state to a plugin: write parameter values, snap smoothers, then hand the optional extra blob to crate::plugin::PluginRuntime::load_state.
deserialize_state
Deserialize plugin state.
hash_plugin_id
Compute a simple hash of the plugin ID string for state identification.
restore_plugin
Inverse of snapshot_plugin. Validates the envelope’s magic, version, and plugin-ID hash; on success restores parameter values via Params::restore_values and forwards the optional extra payload to Plugin::load_state.
serialize_state
Serialize plugin state: parameter values + extra state. Empty extra slice serializes as the same 0u64 length-prefix that an absent extra block would, so callers don’t need an Option wrapper to express “no extra state”.
shared_plugin_state_hash
Resolve the state-envelope hash every format wrapper stamps into the saved blob. Today this is just hash_plugin_id(info.clap_id), which means the same plugin built as CLAP / VST3 / AU / AAX / VST2 / LV2 produces a single state space - saving in one host and loading in another will round-trip parameter values (provided the Plugin::save_state / load_state extra payload is also format-agnostic).
snapshot_plugin
Serialize a plugin instance into the canonical state envelope - parameter values + optional Plugin::save_state() payload, with the magic / version / plugin-ID header serialize_state writes.