pub enum StateContext {
Project,
Preset {
path: Option<String>,
},
}Expand description
Why a plugin is being handed a state blob.
VST3 lets a plugin ask where the state it is being given came from: the host attaches an
IStreamAttributes list to the IBStream it passes to setState, and the plugin reads the
PresetAttributes::kStateType key from it. The SDK ships Vst::Helpers::isProjectState()
for exactly this — it answers “yes” only for StateType::kProject and “this came from a
preset” for every other value — and plugins use the answer to decide what to restore (a
preset should not, for instance, drag a project’s per-instance routing along with it).
Pass this to Plugin::load_state_with_context. Plugin::load_state uses
StateContext::Project; Plugin::load_vstpreset and Plugin::load_preset use
StateContext::Preset with the file they read.
Variants§
Project
The blob is part of a host session/project restore.
Tags the stream StateType::kProject — “the state is restored from a project loading
or it is saved in a project”.
Preset
The blob came from a standalone preset file.
Tags the stream StateType::kTrackPreset. Of the three values the SDK defines,
kProject is explicitly the project case and kDefault is narrower than it looks —
“the state is restored from a preset (marked as default) or the host wants to store a
default state of the plug-in” — so claiming it for a preset the user picked would tell
the plugin this is its initialization patch. kTrackPreset (“the state is restored from
a track preset”) is the SDK’s remaining preset-file value, and it is what makes
Vst::Helpers::isProjectState() answer “came from a preset” rather than the
“host doesn’t implement this” it returns when the attribute is missing entirely.
Fields
path: Option<String>Full path of the file the state was read from, when the caller knows it.
Published as PresetAttributes::kFilePathStringType (“full file path string (if
available) where the preset comes from”); left off the stream when None.
Text rather than a PathBuf because it is published as a UTF-16 stream attribute
and crosses the process-isolation boundary as JSON, neither of which can carry a
non-UTF-8 path. StateContext::preset_from_path does the lossy conversion once,
where it is visible.
Implementations§
Source§impl StateContext
impl StateContext
Trait Implementations§
Source§impl Clone for StateContext
impl Clone for StateContext
Source§fn clone(&self) -> StateContext
fn clone(&self) -> StateContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more