Guest

Trait Guest 

Source
pub trait Guest {
    // Required methods
    fn get_manifest() -> NodeManifest;
    fn get_shader_source() -> String;
    fn execute_custom_action(
        action_id: String,
        current_params: Vec<ParamValue>,
        beat_info: Option<BeatInfo>,
    ) -> Result<Vec<ParamUpdate>, ActionError>;
    fn execute_param_compute(
        current_params: Vec<ParamValue>,
        source_values: Vec<ParamValue>,
        beat_info: Option<BeatInfo>,
    ) -> Result<Vec<ControlOutput>, ActionError>;
}

Required Methods§

Source

fn get_manifest() -> NodeManifest

§========================================================================== Exported Functions

Get node manifest

Called once during plugin load to retrieve node metadata. This is the primary definition export.

The host will:

  1. Validate api-version
  2. Calculate parameter buffer layout from parameters
  3. Build UI from widget configurations
  4. Store this definition for instantiation
Source

fn get_shader_source() -> String

Get WGSL shader source code

Called once during plugin load to retrieve the shader. The shader must follow binding conventions:

  • @group(0): System globals (time, resolution, mouse) - Host-managed
  • @group(1) @binding(0): Node parameters uniform buffer
  • @group(2) @binding(N): Textures (N from texture-port.binding-slot)

The host will:

  1. Parse and validate WGSL with naga
  2. Verify bindings match manifest
  3. Compile to GPU pipeline
Source

fn execute_custom_action( action_id: String, current_params: Vec<ParamValue>, beat_info: Option<BeatInfo>, ) -> Result<Vec<ParamUpdate>, ActionError>

Execute custom action (optional export)

Called when a custom action is triggered by the user. Standard actions (reset, randomize) are handled by the host.

§Parameters
  • action-id: The action identifier from action-def
  • current-params: Current parameter values (for context-aware actions)
  • beat-info: Optional timing information for beat-sync actions
§Returns
  • Ok: List of parameter updates to apply
  • Err: Action execution error
§Note

If this function is not exported, all actions in the manifest must be standard actions handled by the host.

Source

fn execute_param_compute( current_params: Vec<ParamValue>, source_values: Vec<ParamValue>, beat_info: Option<BeatInfo>, ) -> Result<Vec<ControlOutput>, ActionError>

Execute parameter computation (optional export)

Called each frame for nodes with ParamCompute actions. Reads parameters from source nodes and computes updates for target nodes.

§Parameters
  • current-params: This node’s current parameter values
  • source-values: Values from source nodes (as specified in param-compute-config)
  • beat-info: Optional beat timing information
§Returns
  • Ok: List of control outputs to send through ports
  • Err: Computation error
§Note

If this function is not exported, ParamCompute actions in the manifest will be ignored.

§Migration

Previously returned list<external-param-update> with hardcoded targets. Now returns list<control-output> where targets are determined by graph connections.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§