Skip to content

Calling a rust move closure from dyon script #747

Open
@obsoleszenz

Description

@obsoleszenz

Hey :)
I'm trying to call a move || closure from dyon, but that doesn't work. Also I wasn't able to figure out how to do something similar with the current library. Maybe someone has an idea?

    pub fn execute<'b>(&mut self, send_dsp_parameter: &dyn FnMut(String, f32) -> ()) {
        let mut module = Module::new();

        module.add_str(
            "set_dsp_parameter",
            move |rt: &mut dyon::Runtime| -> Result<(), String> {
                let value: f64 = rt.pop()?;
                let key: String = rt.pop()?;
                println!("{key} {value}");
                set_dsp_parameter(key, value);
                Ok(())
            },
            Dfn::nl(vec![Type::Str, Type::F64], Type::Void),
        );
        self.runtime
            .run(&mut Arc::new(module))
            .expect("Failed running");
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions