pub struct PatchDef {
pub version: u32,
pub name: String,
pub author: Option<String>,
pub description: Option<String>,
pub tags: Vec<String>,
pub output: Option<String>,
pub modules: Vec<ModuleDef>,
pub cables: Vec<CableDef>,
pub parameters: HashMap<String, f64>,
}alloc only.Expand description
Serializable patch definition
Fields§
§version: u32Schema version. See CURRENT_PATCH_VERSION for the compatibility policy: loaders
accept version <= CURRENT_PATCH_VERSION and reject newer patches.
name: StringPatch metadata
description: Option<String>Optional and additive: the published JSON schema marks tags optional (default []),
so a hand-authored/tool-generated patch that omits the key must still load. serde(default)
keeps deserialization in sync with the schema.
output: Option<String>Name of the module whose output feeds the patch’s stereo out.
Optional and additive: patches written before this field existed omit it, and
Patch::from_def then falls back to its output-node heuristic. Written by
Patch::to_def whenever the patch has an output node set.
modules: Vec<ModuleDef>Module instances
cables: Vec<CableDef>Cable connections
parameters: HashMap<String, f64>Parameter values (key: "module_name.param_id").
param_id is either a control-input port name (its unpatched base value) or an
internal parameter id exposed via ModuleIntrospection. Applied by
Patch::from_def through Patch::set_param_by_id; unknown keys are ignored so
hand-edited files degrade gracefully.
Optional and additive: the schema marks parameters optional (default {}), so a patch
that omits the key must still load. serde(default) keeps deserialization in sync.
Implementations§
Source§impl PatchDef
impl PatchDef
Set the author
Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Set the description
Source§impl PatchDef
impl PatchDef
Sourcepub fn validate(&self) -> ValidationResult
pub fn validate(&self) -> ValidationResult
Validate the patch definition without loading it
This performs structural validation to catch errors early before
attempting to instantiate modules. For full semantic validation
(e.g., checking that port names exist), use validate_with_registry.
Sourcepub fn validate_with_registry(
&self,
registry: &ModuleRegistry,
) -> ValidationResult
pub fn validate_with_registry( &self, registry: &ModuleRegistry, ) -> ValidationResult
Validate the patch definition with registry context
This performs full semantic validation including checking that:
- All module types exist in the registry
- All port references point to existing modules
- All port names exist on their respective modules
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PatchDef
impl<'de> Deserialize<'de> for PatchDef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl FromWasmAbi for PatchDefwhere
Self: DeserializeOwned,
impl FromWasmAbi for PatchDefwhere
Self: DeserializeOwned,
Source§impl IntoWasmAbi for PatchDefwhere
Self: Serialize,
impl IntoWasmAbi for PatchDefwhere
Self: Serialize,
Source§impl OptionFromWasmAbi for PatchDefwhere
Self: DeserializeOwned,
impl OptionFromWasmAbi for PatchDefwhere
Self: DeserializeOwned,
Source§impl OptionIntoWasmAbi for PatchDefwhere
Self: Serialize,
impl OptionIntoWasmAbi for PatchDefwhere
Self: Serialize,
Source§impl Tsify for PatchDef
impl Tsify for PatchDef
const DECL: &'static str = "export interface PatchDef {\n version: number;\n name: string;\n author: string | undefined;\n description: string | undefined;\n tags?: string[];\n output?: string | undefined;\n modules: ModuleDef[];\n cables: CableDef[];\n parameters?: StdMap<string, number>;\n}"
Auto Trait Implementations§
impl Freeze for PatchDef
impl RefUnwindSafe for PatchDef
impl Send for PatchDef
impl Sync for PatchDef
impl Unpin for PatchDef
impl UnsafeUnpin for PatchDef
impl UnwindSafe for PatchDef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.