Skip to main content

PatchDef

Struct PatchDef 

Source
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>,
}
Available on crate feature alloc only.
Expand description

Serializable patch definition

Fields§

§version: u32

Schema version. See CURRENT_PATCH_VERSION for the compatibility policy: loaders accept version <= CURRENT_PATCH_VERSION and reject newer patches.

§name: String

Patch metadata

§author: Option<String>§description: Option<String>§tags: Vec<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

Source

pub fn new(name: impl Into<String>) -> Self

Create a new empty patch definition

Source

pub fn with_author(self, author: impl Into<String>) -> Self

Set the author

Source

pub fn with_description(self, desc: impl Into<String>) -> Self

Set the description

Source

pub fn with_tag(self, tag: impl Into<String>) -> Self

Add a tag

Source

pub fn to_json(&self) -> Result<String, Error>

Serialize to JSON string

Source

pub fn from_json(json: &str) -> Result<Self, Error>

Deserialize from JSON string

Source§

impl PatchDef

Source

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.

Source

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 Clone for PatchDef

Source§

fn clone(&self) -> PatchDef

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PatchDef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PatchDef

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for PatchDef

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl FromWasmAbi for PatchDef
where Self: DeserializeOwned,

Source§

type Abi = <JsType as FromWasmAbi>::Abi

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: Self::Abi) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl IntoWasmAbi for PatchDef
where Self: Serialize,

Source§

type Abi = <JsType as IntoWasmAbi>::Abi

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> Self::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl OptionFromWasmAbi for PatchDef
where Self: DeserializeOwned,

Source§

fn is_none(js: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for PatchDef
where Self: Serialize,

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl Serialize for PatchDef

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Tsify for PatchDef

Source§

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}"

Source§

type JsType = JsType

Available on crate feature wasm-bindgen only.
Source§

fn into_js(&self) -> Result<Self::JsType, Error>
where Self: Serialize,

Available on crate feature js only.
Source§

fn from_js<T>(js: T) -> Result<Self, Error>
where T: Into<JsValue>, Self: DeserializeOwned,

Available on crate feature js only.
Source§

impl WasmDescribe for PatchDef

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.